Message237439
dictionary creation spends a not insignificant amount of time in malloc allocating keys objects. Python has a nice small object allocator that avoids a lot of this overhead and falls back to malloc for larger allocations.
Is there a reason the dictionary does not use that allocator for its keys objects?
doing so e.g. via attached incomplete patch improves small dict creation performance by 15%.
import timeit
print(timeit.repeat("dict(a=5, b=2)"))
with change:
[0.42825599999923725, 0.4272580000015296, 0.4362329999985377]
without
[0.5160610000002634, 0.5181720000000496, 0.518421999999191]
or is there something I am overlooking and the use of PyMem_Malloc instead of PyObject_Malloc is an intentional design decision? |
|
Date |
User |
Action |
Args |
2015-03-07 11:24:41 | jtaylor | set | recipients:
+ jtaylor |
2015-03-07 11:24:41 | jtaylor | set | messageid: <1425727481.08.0.141675339822.issue23601@psf.upfronthosting.co.za> |
2015-03-07 11:24:40 | jtaylor | link | issue23601 messages |
2015-03-07 11:24:40 | jtaylor | create | |
|