Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jvanasco committed Oct 17, 2016
1 parent 14d0c4c commit b007585
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v 0.1.3
improved the previous version with a factory for dumps

v 0.1.2
aliased loads/dumps on multi functions into a local variable; on larger lists this may be faster

Expand Down
2 changes: 1 addition & 1 deletion dogpile_backend_redis_advanced/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dogpile.cache.region import register_backend

__version__ = '0.1.2'
__version__ = '0.1.3'

# name, modulepath, objname
register_backend(
Expand Down
27 changes: 25 additions & 2 deletions dogpile_backend_redis_advanced/cache/backends/redis_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,31 @@
default_loads = pickle.loads


def default_dumps(v):
return pickle.dumps(v, pickle.HIGHEST_PROTOCOL)
def default_dumps_factory():
"""
optimized for the cpython compiler. shaves a tiny bit off.
this turns 'pickle_dumps' into a local variable to the dump function.
original:
0 LOAD_GLOBAL 0 (pickle)
3 LOAD_ATTR 1 (dumps)
6 LOAD_FAST 0 (v)
9 LOAD_GLOBAL 0 (pickle)
12 LOAD_ATTR 2 (HIGHEST_PROTOCOL)
15 CALL_FUNCTION 2
18 RETURN_VALUE
optimized:
0 LOAD_DEREF 0 (dumps)
3 LOAD_FAST 0 (v)
6 LOAD_GLOBAL 0 (pickle)
9 LOAD_ATTR 1 (HIGHEST_PROTOCOL)
12 CALL_FUNCTION 2
15 RETURN_VALUE
"""
_dumps = pickle.dumps
def default_dumps(v):
return _dumps(v, pickle.HIGHEST_PROTOCOL)
return default_dumps
default_dumps = default_dumps_factory()


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down

0 comments on commit b007585

Please sign in to comment.