<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Objects/dictobject.c, branch v2.1.2</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects/dictobject.c?h=v2.1.2</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects/dictobject.c?h=v2.1.2'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2001-05-23T15:07:55Z</updated>
<entry>
<title>Backport Tim's checkin 2.84:</title>
<updated>2001-05-23T15:07:55Z</updated>
<author>
<name>Thomas Wouters</name>
<email>thomas@python.org</email>
</author>
<published>2001-05-23T15:07:55Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=57ceb79406375f0df2237791cd330521bca2f0f6'/>
<id>urn:sha1:57ceb79406375f0df2237791cd330521bca2f0f6</id>
<content type='text'>
SF bug #422121 Insecurities in dict comparison.
Fixed a half dozen ways in which general dict comparison could crash
Python (even cause Win98SE to reboot) in the presence of kay and/or
value comparison routines that mutate the dict during dict comparison.
</content>
</entry>
<entry>
<title>Tim pointed out a remaining vulnerability in popitem(): the</title>
<updated>2001-04-16T00:02:32Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-04-16T00:02:32Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=e04eaec5b60a41b114dd3b7d78c3a389f8534af8'/>
<id>urn:sha1:e04eaec5b60a41b114dd3b7d78c3a389f8534af8</id>
<content type='text'>
PyTuple_New() could *conceivably* clear the dict, so move the test for
an empty dict after the tuple allocation.  It means that we waste time
allocating and deallocating a 2-tuple when the dict is empty, but who
cares.  It also means that when the dict is empty *and* there's no
memory to allocate a 2-tuple, we raise MemoryError, not KeyError --
but that may actually a good idea: if there's no room for a lousy
2-tuple, what are the chances that there's room for a KeyError
instance?
</content>
</entry>
<entry>
<title>Tentative fix for a problem that Tim discovered at the last moment,</title>
<updated>2001-04-15T22:16:26Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-04-15T22:16:26Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=a4dd011259fa6f3079bd0efd95b3a136c0e3c190'/>
<id>urn:sha1:a4dd011259fa6f3079bd0efd95b3a136c0e3c190</id>
<content type='text'>
and reported to python-dev: because we were calling dict_resize() in
PyDict_Next(), and because GC's dict_traverse() uses PyDict_Next(),
and because PyTuple_New() can cause GC, and because dict_items() calls
PyTuple_New(), it was possible for dict_items() to have the dict
resized right under its nose.

The solution is convoluted, and touches several places: keys(),
values(), items(), popitem(), PyDict_Next(), and PyDict_SetItem().

There are two parts to it. First, we no longer call dict_resize() in
PyDict_Next(), which seems to solve the immediate problem.  But then
PyDict_SetItem() must have a different policy about when *it* calls
dict_resize(), because we want to guarantee (e.g. for an algorithm
that Jeremy uses in the compiler) that you can loop over a dict using
PyDict_Next() and make changes to the dict as long as those changes
are only value replacements for existing keys using PyDict_SetItem().
This is done by resizing *after* the insertion instead of before, and
by remembering the size before we insert the item, and if the size is
still the same, we don't bother to even check if we might need to
resize.  An additional detail is that if the dict starts out empty, we
must still resize it before the insertion.

That was the first part. :-)

The second part is to make keys(), values(), items(), and popitem()
safe against side effects on the dict caused by allocations, under the
assumption that if the GC can cause arbitrary Python code to run, it
can cause other threads to run, and it's not inconceivable that our
dict could be resized -- it would be insane to write code that relies
on this, but not all code is sane.

Now, I have this nagging feeling that the loops in lookdict probably
are blissfully assuming that doing a simple key comparison does not
change the dict's size.  This is not necessarily true (the keys could
be class instances after all).  But that's a battle for another day.
</content>
</entry>
<entry>
<title>Make PyDict_Next safe to use for loops that merely modify the values</title>
<updated>2001-03-21T19:23:56Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-03-21T19:23:56Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=6783070ebfa77aeaf7b5db758095e93cf8e2635c'/>
<id>urn:sha1:6783070ebfa77aeaf7b5db758095e93cf8e2635c</id>
<content type='text'>
associated with existing dict keys.
This is a variant of part of Michael Hudson's patch #409864 "lazy fix for
Pings bizarre scoping crash".
</content>
</entry>
<entry>
<title>Rich comparisons:</title>
<updated>2001-01-18T00:39:02Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-01-18T00:39:02Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=b932420cc7808862bc7e87dad7b44748f7735012'/>
<id>urn:sha1:b932420cc7808862bc7e87dad7b44748f7735012</id>
<content type='text'>
- Use PyObject_RichCompareBool() when comparing keys; this makes the
  error handling cleaner.

- There were two implementations for dictionary comparison, an old one
  (#ifdef'ed out) and a new one.  Got rid of the old one, which was
  abandoned years ago.

- In the characterize() function, part of dictionary comparison, use
  PyObject_RichCompareBool() to compare keys and values instead.  But
  continue to use PyObject_Compare() for comparing the final
  (deciding) elements.

- Align the comments in the type struct initializer.

Note: I don't implement rich comparison for dictionaries -- there
doesn't seem to be much to be gained.  (The existing comparison
already decides that shorter dicts are always smaller than longer
dicts.)
</content>
</entry>
<entry>
<title>dict_update has two boundary conditions: a.update(a) and a.update({})</title>
<updated>2001-01-03T22:34:59Z</updated>
<author>
<name>Jeremy Hylton</name>
<email>jeremy@alum.mit.edu</email>
</author>
<published>2001-01-03T22:34:59Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=1fb6088e86ec84eb425b3f589bcb59d47a783b29'/>
<id>urn:sha1:1fb6088e86ec84eb425b3f589bcb59d47a783b29</id>
<content type='text'>
Added test for second one.
</content>
</entry>
<entry>
<title>Add long-overdue docstrings to dict methods.</title>
<updated>2000-12-13T23:18:45Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2000-12-13T23:18:45Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f7f88b11e4da965a3cdaebc419fb66f1eccb0f05'/>
<id>urn:sha1:f7f88b11e4da965a3cdaebc419fb66f1eccb0f05</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Typo repair in comments.  Fell for GregS's .popitem() poke.</title>
<updated>2000-12-13T19:58:25Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2000-12-13T19:58:25Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f1c7c884b32d26cbe8f604dd9038a3af9d0e457a'/>
<id>urn:sha1:f1c7c884b32d26cbe8f604dd9038a3af9d0e457a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Bring comments up to date (e.g., they still said the table had to be</title>
<updated>2000-12-13T01:02:46Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2000-12-13T01:02:46Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=ea8f2bf9ca87d14140c6ba4bc6ac1f5962659b12'/>
<id>urn:sha1:ea8f2bf9ca87d14140c6ba4bc6ac1f5962659b12</id>
<content type='text'>
a prime size, which is in fact never true anymore ...).
</content>
</entry>
<entry>
<title>Add popitem() -- SF patch #102733.</title>
<updated>2000-12-12T22:02:18Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2000-12-12T22:02:18Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=ba6ab84e73bd5808cc9a4ed1ab58c752af6eef04'/>
<id>urn:sha1:ba6ab84e73bd5808cc9a4ed1ab58c752af6eef04</id>
<content type='text'>
</content>
</entry>
</feed>
