[Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators (original) (raw)

Victor Stinner victor.stinner at gmail.com
Wed Jun 19 07:42:08 CEST 2013


Le mercredi 19 juin 2013, Scott Dial a écrit :

On 6/18/2013 4:40 PM, Victor Stinner wrote: > No context argument

I think there is a lack of justification for the extra argument, and the extra argument is not free. The typical use-case for doing this continuation-passing style is when the set of contexts is either unknown, arbitrarily large, or infinite. In other words, when it would be either impossible or impractical to enumerate all of the contexts. However, in this case, we have only 3.

See the use case 3 in examples. Without the context argument, you have to copy/paste 3 times each functions: 3 functions -> 9 functions. I don't like having to copy/paste code, it sounds like a bad design.

And in the latter case, there is no extra indirect branching in the hot-path of the allocators.

Are you concerned by performances? Did you see the Performances section, there is no overhead according to the benchmark suite.

Also, none of the external libraries cited introduce this CPS/ctx stuff.

Oops, the list is incomplete. Copy/paste from the issue:

Some customizable memory allocators I know have an extra parameter "void *opaque" that is passed to all functions:

OTOH, expat, libxml, libmpdec don't have this extra parameter.

Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130619/a207c406/attachment.html>



More information about the Python-Dev mailing list