summaryrefslogtreecommitdiff
path: root/lib/compat.py
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-02-02 19:21:39 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2019-02-02 19:29:20 +0000
commit35ec7ad9c1ecb165eaeb2b8d4dae84ed8bad182b (patch)
tree88669b2a2413bfc04ec68f7dca646e83c3e68643 /lib/compat.py
parent805527fcd6bedc2671a37c59299c1fa9148f9e6e (diff)
downloadpsycopg2-fast-namedtuple.tar.gz
Use a proper LRU cache for namedtuplesfast-namedtuple
Previous one didn't refresh by last use. Use the stdlib version for py3 and one of our own for py2. Max size set to 512, which should be fine for everyone (tweaking is still possible by monkeypatching, as the tests do, but I don't want to make an interface of it).
Diffstat (limited to 'lib/compat.py')
-rw-r--r--lib/compat.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/compat.py b/lib/compat.py
index cfd5a88..185b8f6 100644
--- a/lib/compat.py
+++ b/lib/compat.py
@@ -1,10 +1,15 @@
import sys
+__all__ = ['string_types', 'text_type', 'lru_cache']
+
if sys.version_info[0] == 2:
# Python 2
string_types = basestring,
text_type = unicode
+ from ._lru_cache import lru_cache
+
else:
# Python 3
string_types = str,
text_type = str
+ from functools import lru_cache