Skip to content

Commit

Permalink
Merge pull request #1491 from quantopian/faster-lru-cache-take-2
Browse files Browse the repository at this point in the history
ENH: Switching from cachetools.LRUCache to lru-dict's LRU cache.
  • Loading branch information
jbredeche authored Sep 16, 2016
2 parents 86c7635 + eb7e1fa commit f1dba1d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion conda/cachetools/bld.bat → conda/lru-dict/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ if errorlevel 1 exit 1

:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.
:: for a list of environment variables that are set during the build process.
2 changes: 1 addition & 1 deletion conda/cachetools/build.sh → conda/lru-dict/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ $PYTHON setup.py install

# See
# http://docs.continuum.io/conda/build.html
# for a list of environment variables that are set during the build process.
# for a list of environment variables that are set during the build process.
22 changes: 11 additions & 11 deletions conda/cachetools/meta.yaml → conda/lru-dict/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package:
name: cachetools
version: "1.1.6"
name: lru-dict
version: "1.1.4"

source:
fn: cachetools-1.1.6.tar.gz
url: https://pypi.python.org/packages/source/c/cachetools/cachetools-1.1.6.tar.gz
md5: 387d7f34effd9335ae55bd0762e77bfa
fn: lru-dict-1.1.4.tar.gz
url: https://files.pythonhosted.org/packages/c3/b7/4e5bcbdfdc2227001f897051d6f4c83f9d236fe89a9df74da07cc3d9bac8/lru-dict-1.1.4.tar.gz
md5: 95ed142416b32c4b03dd8e7dae924f38
# patches:
# List any patch files here
# - fix.patch
Expand All @@ -17,9 +17,9 @@ source:
# Put any entry points (scripts to be generated automatically) here. The
# syntax is module:function. For example
#
# - cachetools = cachetools:main
# - lru-dict = lru-dict:main
#
# Would create an entry point called cachetools that calls cachetools.main()
# Would create an entry point called lru-dict that calls lru-dict.main()


# If this is a new build for the same version, increment the build
Expand All @@ -37,7 +37,7 @@ requirements:
test:
# Python imports
imports:
- cachetools
- lru

# commands:
# You can put test commands to be run here. Use this to test that the
Expand All @@ -52,10 +52,10 @@ test:
# - nose

about:
home: https://github.com/tkem/cachetools
home: https://github.com/amitdev/lru-dict
license: MIT License
summary: 'Extensible memoizing collections and decorators'
summary: 'A fast and memory efficient LRU cache.'

# See
# http://docs.continuum.io/conda/build.html for
# more information about meta.yaml
# more information about meta.yaml
3 changes: 2 additions & 1 deletion etc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ alembic==0.7.7
sortedcontainers==1.4.4
intervaltree==2.1.0

cachetools==1.1.5
# for caching
lru-dict==1.1.4

# For financial risk calculations
empyrical==0.1.11
4 changes: 2 additions & 2 deletions zipline/data/history_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
abstractmethod,
abstractproperty,
)
from lru import LRU

from cachetools import LRUCache
from numpy import around, hstack
from pandas import Int64Index

Expand Down Expand Up @@ -89,7 +89,7 @@ def __init__(self, trading_calendar, reader, adjustment_reader,
self._reader = reader
self._adjustments_reader = adjustment_reader
self._window_blocks = {
field: ExpiringCache(LRUCache(maxsize=sid_cache_size))
field: ExpiringCache(LRU(sid_cache_size))
for field in self.FIELDS
}

Expand Down
4 changes: 2 additions & 2 deletions zipline/data/minute_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from os.path import join
from textwrap import dedent

from cachetools import LRUCache
from lru import LRU
import bcolz
from bcolz import ctable
from intervaltree import IntervalTree
Expand Down Expand Up @@ -788,7 +788,7 @@ def __init__(self, rootdir, sid_cache_size=1000):
self._minutes_per_day = metadata.minutes_per_day

self._carrays = {
field: LRUCache(maxsize=sid_cache_size)
field: LRU(sid_cache_size)
for field in self.FIELDS
}

Expand Down

0 comments on commit f1dba1d

Please sign in to comment.