On Thu, 19 Jul 2012 19:53:27 +0300 M Stefan <mstefa...@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 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com