Message276868
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. |
|
Date |
User |
Action |
Args |
2016-09-18 02:00:04 | rhettinger | set | recipients:
+ rhettinger, vstinner, ned.deily, methane, serhiy.storchaka, xiang.zhang |
2016-09-18 02:00:04 | rhettinger | set | messageid: <1474164004.36.0.931226370844.issue28183@psf.upfronthosting.co.za> |
2016-09-18 02:00:04 | rhettinger | link | issue28183 messages |
2016-09-18 02:00:03 | rhettinger | create | |
|