Skip to content

Commit 097579e

Browse files
author
ldx
committed
Use dict as Table cache.
For both IPv4 and IPv6, use a dict instead of a weakref cache. This makes the cache a permanent one, and avoids the overhead of creating/freeing tables too often.
1 parent 1dd825c commit 097579e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

iptc/ip4tc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ class Table(object):
13181318
ALL = ["filter", "mangle", "raw", "nat"]
13191319
"""This is the constant for all tables."""
13201320

1321-
_cache = weakref.WeakValueDictionary()
1321+
_cache = dict()
13221322

13231323
def __new__(cls, name, autocommit=None):
13241324
obj = Table._cache.get(name, None)

iptc/ip6tc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ class Table6(Table):
569569
ALL = ["filter", "mangle", "raw", "security"]
570570
"""This is the constant for all tables."""
571571

572-
_cache = weakref.WeakValueDictionary()
572+
_cache = dict()
573573

574574
def __new__(cls, name, autocommit=None):
575575
obj = Table6._cache.get(name, None)

0 commit comments

Comments
 (0)