[Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators (original) (raw)
Kristján Valur Jónsson kristjan at ccpgames.com
Wed Jun 19 17:31:35 CEST 2013
- Previous message: [Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators
- Next message: [Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Right, think of the "ctxt" as a "this" pointer from c++. If you have an allocator object, that you got from some c++ api, and want to ask Python to use that, you need to be able to thunk the "this" pointer to get at the particular allocator instance. It used to be a common mistake when writing C callback apis to forget to add an opaque "context" pointer along with the callback function. This omission makes it difficult (but not impossible) to attach c++ methods to such callbacks.
K
-----Original Message----- From: Python-Dev [mailto:python-dev-_ _bounces+kristjan=ccpgames.com at python.org] On Behalf Of Scott Dial Sent: 19. júní 2013 04:34 To: ncoghlan at gmail.com Cc: Python-Dev at python.org Subject: Re: [Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators
On 6/18/2013 11:32 PM, Nick Coghlan wrote: > Agreed more of that rationale needs to be moved from the issue tracker > into the PEP, though. Thanks for the clarification. I hadn't read the issue tracker at all. On it's face value, I didn't see what purpose it served, but having read Kristján's comments on the issue tracker, he would like to store state for the allocators in that ctx pointer.[1] Having read that (previously, I thought the only utility was distinguishing which domain it was -- a small, glorified enumeration), but his use-case makes sense and definitely is informative to have in the PEP, because the utility of that wasn't obvious to me. Thanks, -Scott [1] http://bugs.python.org/issue3329#msg190529 """ One particular trick we have been using, which might be of interest, is to be able to tag each allocation with a "context" id. This is then set according to a global sys.memcontext variable, which the program will modify according to what it is doing. This can then be used to track memory usage by different parts of the program. """ -- Scott Dial scott at scottdial.com
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python- dev/kristjan%40ccpgames.com
- Previous message: [Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators
- Next message: [Python-Dev] RFC: PEP 445: Add new APIs to customize Python memory allocators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]