A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-December/070334.html below:

[Python-Dev] Creating dicts from dict subclasses

[Python-Dev] Creating dicts from dict subclasses [Python-Dev] Creating dicts from dict subclassesWalter Dörwald walter at livinglogic.de
Wed Dec 13 17:57:16 CET 2006
I tried to reimplement weakref.WeakValueDictionary as a subclass of
dict. The test passes except for one problem: To compare results
test_weakref.py converts a weakdict to a real dict via dict(weakdict).
This no longer works because PyDict_Merge() does a PyDict_Check() on the
argument and then ignores all overwritten methods. (The old version
worked because UserDict.UserDict was used).

The simplest solution is to replace the PyDict_Check() call with
PyDict_CheckExact(), but this might slow things down too much, because
the fallback code basically does:

   for key in iter(arg.keys()):
      self[key] = arg.__getitem__(key)

Why can't we use:

   for key in iter(arg):
      self[key] = arg.__getitem__(key)

instead?

Servus,
   Walter
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4