summaryrefslogtreecommitdiff
path: root/Lib/abc.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-10-23 06:26:46 +0000
committerGeorg Brandl <georg@python.org>2007-10-23 06:26:46 +0000
commit3b8cb17695209c48bfc618ba265d201e81d1603a (patch)
tree104dda0dd1ec84e9c8eacf05194cacb5698c9f36 /Lib/abc.py
parentb98dd2e5d2133b1c8cebd1dd221cf69eefeb154f (diff)
downloadcpython-git-3b8cb17695209c48bfc618ba265d201e81d1603a.tar.gz
#1061 (mainly by Thomas Wouters): use weak sets for abc caches.
Diffstat (limited to 'Lib/abc.py')
-rw-r--r--Lib/abc.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/abc.py b/Lib/abc.py
index f8e0230278..54dc8e2d97 100644
--- a/Lib/abc.py
+++ b/Lib/abc.py
@@ -3,6 +3,7 @@
"""Abstract Base Classes (ABCs) according to PEP 3119."""
+from weakref import WeakSet
def abstractmethod(funcobj):
"""A decorator indicating abstract methods.
@@ -130,9 +131,9 @@ class ABCMeta(type):
abstracts.add(name)
cls.__abstractmethods__ = abstracts
# Set up inheritance registry
- cls._abc_registry = set()
- cls._abc_cache = set()
- cls._abc_negative_cache = set()
+ cls._abc_registry = WeakSet()
+ cls._abc_cache = WeakSet()
+ cls._abc_negative_cache = WeakSet()
cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
return cls
@@ -172,7 +173,7 @@ class ABCMeta(type):
# Check negative cache; may have to invalidate
if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
# Invalidate the negative cache
- cls._abc_negative_cache = set()
+ cls._abc_negative_cache = WeakSet()
cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
elif subclass in cls._abc_negative_cache:
return False