New submission from Julian Taylor: 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? ---------- components: Interpreter Core files: 0001-use-small-object-allocator-for-keys-object.patch keywords: patch messages: 237439 nosy: jtaylor priority: normal severity: normal status: open title: use small object allocator for dict key storage versions: Python 3.5 Added file: http://bugs.python.org/file38371/0001-use-small-object-allocator-for-keys-object.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23601> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com