Issue 614555: Rewrite _reduce and _reconstructor in C (original) (raw)
Issue614555
Created on 2002-09-25 18:15 by gvanrossum, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Messages (7) | ||
---|---|---|
msg12478 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2002-09-25 18:15 |
The copy_reg defines two functions, _reduce() and _reconstructor(), that are used for the pickling and unpickling of new-style classes. These were originally written in Python because the right implementation wasn't entirely clear; _reduce() is actually called from a C-level __reduce__ method defined in 'object', and it references _reconstructor() in its return tuple. It is now time to move both back into C for efficiency. | ||
msg12479 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2002-11-14 16:46 |
Logged In: YES user_id=6380 I'd like to add some comments from Jim Fulton on this (or a related) issue so they don't get lost. """ I still need to think of a good way to handle this. Currently, the pattern is a reduce return value of the form: reconstructor, (some_class, object, None), some_state but there is a more general case where an uninitialized object can be gotten by calling "type.__new__(some_class)", or even: "some_class.__new__(some_class)". There are really two issues: - It's too hard to write __reduce__ functions for this case, and - Too much data needs to be stored in pickles. A new pickling code would handler the later, but I also want to solve the former problem. One thought is to return: (copy_reg.new, (some_class, ), some_state) where copy_reg.new is: def new(class_): return class.__new__(class_) The pickler could easily spot reduce returns with copy_reg.new as the first value and generate a special pickle code. """ | ||
msg12480 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2003-02-12 22:19 |
Logged In: YES user_id=6380 Lowering priority; when you use pickle protocol 2, none of this Python code is used any more. Jim's comment has been addressed by __newobj__ and __getnewargs__ (see PEP 307). | ||
msg12481 - (view) | Author: Tim Peters (tim.peters) * ![]() |
Date: 2003-02-14 02:27 |
Logged In: YES user_id=31435 Except that the new Python code _better_reduce() is used then. As discussed, I intend to rewrite _reduce and _better_reduce in C, inside object's __reduce__ implementation, so I assigned this to me and boosted the priority. I don't intend to recode _reconstructor in C, though. | ||
msg12482 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2003-02-19 22:38 |
Logged In: YES user_id=6380 This isn't going to be done for 2.3a2; we'll revisit who gets to do it closer to 2.3b1. | ||
msg55903 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2007-09-13 23:54 |
Classifying as an RFE since this is not critical (as shown by it not happening since early 2003). | ||
msg59200 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2008-01-04 01:13 |
I just don't see this happening. Possibly it's out of date. Lots of things have changed in the pickle world since 2002. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:42 | admin | set | github: 37217 |
2008-01-04 01:13:17 | gvanrossum | set | status: open -> closedresolution: wont fixmessages: + |
2008-01-04 00:43:58 | christian.heimes | set | versions: + Python 2.6, Python 2.5, - Python 2.3 |
2007-12-06 00:44:40 | alexandre.vassalotti | set | nosy: + alexandre.vassalotti |
2007-09-13 23:54:29 | brett.cannon | set | type: enhancementmessages: + nosy: + brett.cannon |
2002-09-25 18:15:01 | gvanrossum | create |