<feed xmlns='http://www.w3.org/2005/Atom'>
<title>python.git/Objects/dictobject.c, branch v2.2.1</title>
<subtitle>Python interpreter</subtitle>
<id>http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects/dictobject.c?h=v2.2.1</id>
<link rel='self' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/atom/Objects/dictobject.c?h=v2.2.1'/>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/'/>
<updated>2002-03-28T20:36:50Z</updated>
<entry>
<title>Backport to 2.2.1:</title>
<updated>2002-03-28T20:36:50Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2002-03-28T20:36:50Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=9ff1cf05fbcee1b98a4fc53ed12dc9b134a26f2f'/>
<id>urn:sha1:9ff1cf05fbcee1b98a4fc53ed12dc9b134a26f2f</id>
<content type='text'>
This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction).

The fix makes it possible to call PyObject_GC_UnTrack() more than once
on the same object, and then move the PyObject_GC_UnTrack() call to
*before* the trashcan code is invoked.

BUGFIX CANDIDATE!
</content>
</entry>
<entry>
<title>SF bug #491415 PyDict_UpdateFromSeq2() unused</title>
<updated>2001-12-11T18:51:08Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-12-11T18:51:08Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=f582b82fe9ae4c0394ed4f6b281aa8b4ca224617'/>
<id>urn:sha1:f582b82fe9ae4c0394ed4f6b281aa8b4ca224617</id>
<content type='text'>
PyDict_UpdateFromSeq2():  removed it.
PyDict_MergeFromSeq2():  made it public and documented it.
PyDict_Merge() docs:  updated to reveal &lt;wink&gt; that the second
argument can be any mapping object.
</content>
</entry>
<entry>
<title>Fix of SF bug #475877 (Mutable subtype instances are hashable).</title>
<updated>2001-12-03T16:32:18Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-12-03T16:32:18Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=dbb53d99189075522eecc87723292c85aee15388'/>
<id>urn:sha1:dbb53d99189075522eecc87723292c85aee15388</id>
<content type='text'>
Rather than tweaking the inheritance of type object slots (which turns
out to be too messy to try), this fix adds a __hash__ to the list and
dict types (the only mutable types I'm aware of) that explicitly
raises an error.  This has the advantage that list.__hash__([]) also
raises an error (previously, this would invoke object.__hash__([]),
returning the argument's address); ditto for dict.__hash__.

The disadvantage for this fix is that 3rd party mutable types aren't
automatically fixed.  This should be added to the rules for creating
subclassable extension types: if you don't want your object to be
hashable, add a tp_hash function that raises an exception.

Also, it's possible that I've forgotten about other mutable types for
which this should be done.
</content>
</entry>
<entry>
<title>Rename "dictionary" (type and constructor) to "dict".</title>
<updated>2001-10-29T22:25:45Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-10-29T22:25:45Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=a427a2b8d09a756119d424efac85159a0270b503'/>
<id>urn:sha1:a427a2b8d09a756119d424efac85159a0270b503</id>
<content type='text'>
</content>
</entry>
<entry>
<title>dictionary() constructor:</title>
<updated>2001-10-27T18:27:48Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-10-27T18:27:48Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=4d85953fe609197c54827826963eabaf6418024c'/>
<id>urn:sha1:4d85953fe609197c54827826963eabaf6418024c</id>
<content type='text'>
+ Change keyword arg name from "x" to "items".  People passing a mapping
  object can stretch their imaginations &lt;wink&gt;.
+ Simplify the docstring text.
</content>
</entry>
<entry>
<title>Generalize dictionary() to accept a sequence of 2-sequences.  At the</title>
<updated>2001-10-26T05:06:50Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-10-26T05:06:50Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=1fc240e85150f5cb39502a87cc9a4a0a8cbe5ab0'/>
<id>urn:sha1:1fc240e85150f5cb39502a87cc9a4a0a8cbe5ab0</id>
<content type='text'>
outer level, the iterator protocol is used for memory-efficiency (the
outer sequence may be very large if fully materialized); at the inner
level, PySequence_Fast() is used for time-efficiency (these should
always be sequences of length 2).

dictobject.c, new functions PyDict_{Merge,Update}FromSeq2.  These are
wholly analogous to PyDict_{Merge,Update}, but process a sequence-of-2-
sequences argument instead of a mapping object.  For now, I left these
functions file static, so no corresponding doc changes.  It's tempting
to change dict.update() to allow a sequence-of-2-seqs argument too.

Also changed the name of dictionary's keyword argument from "mapping"
to "x".  Got a better name?  "mapping_or_sequence_of_pairs" isn't
attractive, although more so than "mosop" &lt;wink&gt;.

abstract.h, abstract.tex:  Added new PySequence_Fast_GET_SIZE function,
much faster than going thru the all-purpose PySequence_Size.

libfuncs.tex:
- Document dictionary().
- Fiddle tuple() and list() to admit that their argument is optional.
- The long-winded repetitions of "a sequence, a container that supports
  iteration, or an iterator object" is getting to be a PITA.  Many
  months ago I suggested factoring this out into "iterable object",
  where the definition of that could include being explicit about
  generators too (as is, I'm not sure a reader outside of PythonLabs
  could guess that "an iterator object" includes a generator call).
- Please check my curly braces -- I'm going blind &lt;0.9 wink&gt;.

abstract.c, PySequence_Tuple():  When PyObject_GetIter() fails, leave
its error msg alone now (the msg it produces has improved since
PySequence_Tuple was generalized to accept iterable objects, and
PySequence_Tuple was also stomping on the msg in cases it shouldn't
have even before PyObject_GetIter grew a better msg).
</content>
</entry>
<entry>
<title>Enable GC for new-style instances.  This touches lots of files, since</title>
<updated>2001-10-05T20:51:39Z</updated>
<author>
<name>Guido van Rossum</name>
<email>guido@python.org</email>
</author>
<published>2001-10-05T20:51:39Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=9475a2310d9cdec4b4c36dee8bf30c72605ae928'/>
<id>urn:sha1:9475a2310d9cdec4b4c36dee8bf30c72605ae928</id>
<content type='text'>
many types were subclassable but had a xxx_dealloc function that
called PyObject_DEL(self) directly instead of deferring to
self-&gt;ob_type-&gt;tp_free(self).  It is permissible to set tp_free in the
type object directly to _PyObject_Del, for non-GC types, or to
_PyObject_GC_Del, for GC types.  Still, PyObject_DEL was a tad faster,
so I'm fearing that our pystone rating is going down again.  I'm not
sure if doing something like

void xxx_dealloc(PyObject *self)
{
	if (PyXxxCheckExact(self))
		PyObject_DEL(self);
	else
		self-&gt;ob_type-&gt;tp_free(self);
}

is any faster than always calling the else branch, so I haven't
attempted that -- however those types whose own dealloc is fancier
(int, float, unicode) do use this pattern.
</content>
</entry>
<entry>
<title>Changed the dict implementation to take "string shortcuts" only when</title>
<updated>2001-09-14T00:25:33Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-09-14T00:25:33Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=0ab085c4cba79c1743288a300425b3c9050250ba'/>
<id>urn:sha1:0ab085c4cba79c1743288a300425b3c9050250ba</id>
<content type='text'>
keys are true strings -- no subclasses need apply.  This may be debatable.

The problem is that a str subclass may very well want to override __eq__
and/or __hash__ (see the new example of case-insensitive strings in
test_descr), but go-fast shortcuts for strings are ubiquitous in our dicts
(and subclass overrides aren't even looked for then).  Another go-fast
reason for the change is that PyCheck_StringExact() is a quicker test
than PyCheck_String(), and we make such a test on virtually every access
to every dict.

OTOH, a str subclass may also be perfectly happy using the base str eq
and hash, and this change slows them a lot.  But those cases are still
hypothetical, while Python's own reliance on true-string dicts is not.
</content>
</entry>
<entry>
<title>Repair typo in comment.</title>
<updated>2001-09-02T18:35:54Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-09-02T18:35:54Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=b95ec09a44d59c57a68591e35df10f583c86a1aa'/>
<id>urn:sha1:b95ec09a44d59c57a68591e35df10f583c86a1aa</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Make dictionary() a real constructor.  Accepts at most one argument, "a</title>
<updated>2001-09-02T08:22:48Z</updated>
<author>
<name>Tim Peters</name>
<email>tim.peters@gmail.com</email>
</author>
<published>2001-09-02T08:22:48Z</published>
<link rel='alternate' type='text/html' href='http://dangofactory.net/cgit/cgit.cgi/Server/python.git/commit/?id=25786c0851da8665bdbba948ddb16b23a040bbb2'/>
<id>urn:sha1:25786c0851da8665bdbba948ddb16b23a040bbb2</id>
<content type='text'>
mapping object", in the same sense dict.update(x) requires of x (that x
has a keys() method and a getitem).
Questionable:  The other type constructors accept a keyword argument, so I
did that here too (e.g., dictionary(mapping={1:2}) works).  But type_call
doesn't pass the keyword args to the tp_new slot (it passes NULL), it only
passes them to the tp_init slot, so getting at them required adding a
tp_init slot to dicts.  Looks like that makes the normal case (i.e., no
args at all) a little slower (the time it takes to call dict.tp_init and
have it figure out there's nothing to do).
</content>
</entry>
</feed>
