Author jtaylor
Recipients jtaylor
Date 2015-03-07.11:24:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425727481.08.0.141675339822.issue23601@psf.upfronthosting.co.za>
In-reply-to
Content
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?
History
Date User Action Args
2015-03-07 11:24:41jtaylorsetrecipients: + jtaylor
2015-03-07 11:24:41jtaylorsetmessageid: <1425727481.08.0.141675339822.issue23601@psf.upfronthosting.co.za>
2015-03-07 11:24:40jtaylorlinkissue23601 messages
2015-03-07 11:24:40jtaylorcreate