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 <1474164004.36.0.931226370844.issue28183@psf.upfronthosting.co.za>
In-reply-to
Content
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 https://code.activestate.com/recipes/578375

    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:
                    break
            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.
History
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: <1474164004.36.0.931226370844.issue28183@psf.upfronthosting.co.za>
2016-09-18 02:00:04rhettingerlinkissue28183 messages
2016-09-18 02:00:03rhettingercreate