-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key expiration does not work with Python 3.5 #16
Comments
We see this on our internal fork of expiringdict as well. It is a regression introduced by the "optimized" version of OrderedDict introduced in Python 3.5. The regression is reported here: http://bugs.python.org/issue27275 In the meantime you can force Python to give you a copy of the pure python version by doing this to import import sys
# Python 3.5 has a broken 'optimised' version of OrderedDict which can corrupt itself at high load.
if sys.version_info.major == 3 and sys.version_info.minor == 5:
from test import support
py_coll = support.import_fresh_module('collections', blocked=['_collections'])
OrderedDict = py_coll.OrderedDict
else:
from collections import OrderedDict To be perfectly honest, I don't know why this has been included. I see no notable performance change between the C and Python versions. On our codebase, 10k+ iterations/sec of expiringdict accesses we see no change in performance between the C and Python version of OrderedDict. Something something premature optimization is the root of all evil. |
any news on this PR? |
Python 3.6 resolves the regression, but honestly we don't even need OrderedDict there for this particular use. |
I wanted to use this project, but it's abandoned and unmaintained. I ended up using https://pythonhosted.org/cachetools/#cachetools.TTLCache instead. |
Greetings from 2020! |
I guess the inherited OrderedDict implementation has changed.
I do not use ttl or iteration, so I have fixed my use case with an extra try around the
popitem(last=False)
in__setitem__
.The text was updated successfully, but these errors were encountered: