This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author loewis
Recipients
Date 2007-02-06.20:03:44
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
ked-tao: as for "doesn't really explain", please take a look at this comment:

        /* Set ep to "the first" dict entry with a value.  We abuse the hash
         * field of slot 0 to hold a search finger:
         * If slot 0 has a value, use slot 0.
         * Else slot 0 is being used to hold a search finger,
         * and we use its hash value as the first index to look.
         */

So .popitem first returns (and removes) the item in slot 0. Afterwards, it does a 
linear scan through the dictionary, returning one item at a time. To avoid
re-scanning the emptying dictionary over and over again, the me_hash
value of slot 0 indicates the place to start searching when the next .popitem
call is made. Of course, this value may start out bogus and out-of-range,
or may become out-of-range if the dictionary shrinks; in that case, it
starts over at index 1. If it is bogus (i.e. never set as a search finger)
and in-range, that's fine: it will just start searching for a non-empty
slot at me_hash.

Because it is a slot number, me_hash must be large enough to hold a
Py_ssize_t. On some systems (Win64 in particular), long is not large
enough to hold Py_ssize_t.

I believe the proposed patch is fine.
History
Date User Action Args
2007-08-23 14:51:35adminlinkissue1646068 messages
2007-08-23 14:51:35admincreate