[pypy-commit] pypy set-strategies: frozenset does not need to be copied
l.diekmann
noreply at buildbot.pypy.org
Thu Nov 10 13:51:19 CET 2011
Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: set-strategies
Changeset: r49206:8592d5651c05
Date: 2011-10-10 11:10 +0200
http://bitbucket.org/pypy/pypy/changeset/8592d5651c05/
Log: frozenset does not need to be copied
diff --git a/pypy/objspace/std/setobject.py b/pypy/objspace/std/setobject.py
--- a/pypy/objspace/std/setobject.py
+++ b/pypy/objspace/std/setobject.py
@@ -28,7 +28,6 @@
def __init__(w_self, space, w_iterable=None):
"""Initialize the set by taking ownership of 'setdata'."""
w_self.space = space #XXX less memory without this indirection?
- #XXX in case of ObjectStrategy we can reuse the setdata object
set_strategy_and_setdata(space, w_self, w_iterable)
def __repr__(w_self):
@@ -314,10 +313,12 @@
w_set.switch_to_empty_strategy()
def copy(self, w_set):
- #XXX do not copy FrozenDict
- d = self.cast_from_void_star(w_set.sstorage)
strategy = w_set.strategy
- storage = self.cast_to_void_star(d.copy())
+ if isinstance(w_set, W_FrozensetObject):
+ storage = w_set.sstorage
+ else:
+ d = self.cast_from_void_star(w_set.sstorage)
+ storage = self.cast_to_void_star(d.copy())
clone = w_set.from_storage_and_strategy(storage, strategy)
return clone
More information about the pypy-commit
mailing list