summaryrefslogtreecommitdiff
path: root/Lib/test/pickletester.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-05-02 21:41:14 +0000
committerAntoine Pitrou <solipsis@pitrou.net>2009-05-02 21:41:14 +0000
commita9f48a0d4f0bad22275b5feb78f63a8a8f00a6f8 (patch)
tree2b8fe03afda19f7380363d50af4934b0b4893a1b /Lib/test/pickletester.py
parent6fa98fb7ecee40329c5e8d74f583272ffedc97f9 (diff)
downloadcpython-git-a9f48a0d4f0bad22275b5feb78f63a8a8f00a6f8.tar.gz
Merged revisions 72223 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72223 | antoine.pitrou | 2009-05-02 23:13:23 +0200 (sam., 02 mai 2009) | 5 lines Isue #5084: unpickling now interns the attribute names of pickled objects, saving memory and avoiding growth in size of subsequent pickles. Proposal and original patch by Jake McGuire. ........
Diffstat (limited to 'Lib/test/pickletester.py')
-rw-r--r--Lib/test/pickletester.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index e3a929fb8d..1585586d3d 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -932,6 +932,20 @@ class AbstractPickleTests(unittest.TestCase):
"Failed protocol %d: %r != %r"
% (proto, obj, loaded))
+ def test_attribute_name_interning(self):
+ # Test that attribute names of pickled objects are interned when
+ # unpickling.
+ for proto in protocols:
+ x = C()
+ x.foo = 42
+ x.bar = "hello"
+ s = self.dumps(x, proto)
+ y = self.loads(s)
+ x_keys = sorted(x.__dict__)
+ y_keys = sorted(y.__dict__)
+ for x_key, y_key in zip(x_keys, y_keys):
+ self.assertIs(x_key, y_key)
+
# Test classes for reduce_ex
class REX_one(object):