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 jtaylor
Recipients jtaylor
Date 2015-03-07.11:24:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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]
[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:41jtaylorsetrecipients: + jtaylor
2015-03-07 11:24:41jtaylorsetmessageid: <>
2015-03-07 11:24:40jtaylorlinkissue23601 messages
2015-03-07 11:24:40jtaylorcreate