Author: Mark Young <marky1...@gmail.com> Branch: py3.3 Changeset: r82199:41b2dabb978a Date: 2016-02-12 21:16 -0500 http://bitbucket.org/pypy/pypy/changeset/41b2dabb978a/
Log: Don't do an O(n) membership check on the dict's keys. Just do the O(1) membership check in the dict itself. diff --git a/pypy/interpreter/mixedmodule.py b/pypy/interpreter/mixedmodule.py --- a/pypy/interpreter/mixedmodule.py +++ b/pypy/interpreter/mixedmodule.py @@ -66,13 +66,12 @@ # overwrite the value of a key already in w_initialdict. (So as to avoid # overriding the builtin value with a user-provided value) if not self.space.is_none(self.w_initialdict): - w_present_keys = self.w_initialdict.w_keys() new_items = self.w_dict.iteritems() while True: w_key, w_value = new_items.next_item() if w_key is None: break - if not self.space.is_true(self.space.contains(w_present_keys, w_key)): + if not self.space.is_true(self.space.contains(self.w_initialdict, w_key)): self.space.setitem(self.w_initialdict, w_key, w_value) else: self.w_initialdict = self.space.call_method(self.w_dict, 'copy') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit