[Python-Dev] Unbinding of methods (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Thu Jul 19 20:54:08 CEST 2012
- Previous message: [Python-Dev] Unbinding of methods
- Next message: [Python-Dev] Unbinding of methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 19 Jul 2012 19:53:27 +0300 M Stefan <mstefanro at gmail.com> wrote:
Hey,
As part of pickle4, I found it interesting to add the possibility of pickling bound functions (instance methods). This is done by pickling f.self and f.func separately, and then adding a BIND opcode to tie them together.
Instead of a specific opcode, can't you use a suitable reduce magic (or getnewargs, perhaps)? We want to limit the number of opcodes except for performance-critical types (and I don't think bound methods are performance-critical for the purpose of serialization).
I have created a patch at [1], which adds func to some other function types, as well as: 1) adds AllFunctionTypes etc. to Lib/types.py 2) inspect.isanyfunction(), inspect.isanyboundfunction(), inspect.isanyunboundfunction() 3) functools.unbind
That sounds like a lot of changes if the goal is simply to make those types picklable.
Regards
Antoine.
-- Software development and contracting: http://pro.pitrou.net
- Previous message: [Python-Dev] Unbinding of methods
- Next message: [Python-Dev] Unbinding of methods
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]