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 rhettinger
Recipients methane, ned.deily, rhettinger, serhiy.storchaka, vstinner, xiang.zhang
Date 2016-09-18.02:00:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Also, please take a look at resizing.  It looks like it is doing way too much work.  The original keys, values, and hashes shouldn't move at all, only the indices array needs to updated.

Here is the pure python version from the original proof-of-concept at

    def _resize(self, n):
        '''Reindex the existing hash/key/value entries.
           Entries do not get moved, they only get new indices.
           No calls are made to hash() or __eq__().

        n = 2 ** n.bit_length()                     # round-up to power-of-two
        self.indices = self._make_index(n)
        for index, hashvalue in enumerate(self.hashlist):
            for i in Dict._gen_probes(hashvalue, n-1):
                if self.indices[i] == FREE:
            self.indices[i] = index
        self.filled = self.used

Likewise, it looks like there is room for improvement in dict_copy().  It can memcpy() all four arrays and then incref all the keys.  That should be considerably faster than zeroing new arrays and applying re-insertion logic.
Date User Action Args
2016-09-18 02:00:04rhettingersetrecipients: + rhettinger, vstinner, ned.deily, methane, serhiy.storchaka, xiang.zhang
2016-09-18 02:00:04rhettingersetmessageid: <>
2016-09-18 02:00:04rhettingerlinkissue28183 messages
2016-09-18 02:00:03rhettingercreate