Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite _reduce and _reconstructor in C #37217

Closed
gvanrossum opened this issue Sep 25, 2002 · 7 comments
Closed

Rewrite _reduce and _reconstructor in C #37217

gvanrossum opened this issue Sep 25, 2002 · 7 comments
Assignees
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@gvanrossum
Copy link
Member

BPO 614555
Nosy @gvanrossum, @tim-one, @brettcannon, @avassalotti

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/gvanrossum'
closed_at = <Date 2008-01-04.01:13:17.995>
created_at = <Date 2002-09-25.18:15:01.000>
labels = ['interpreter-core', 'type-feature']
title = 'Rewrite _reduce and _reconstructor in C'
updated_at = <Date 2008-01-04.01:13:17.994>
user = 'https://github.com/gvanrossum'

bugs.python.org fields:

activity = <Date 2008-01-04.01:13:17.994>
actor = 'gvanrossum'
assignee = 'gvanrossum'
closed = True
closed_date = <Date 2008-01-04.01:13:17.995>
closer = 'gvanrossum'
components = ['Interpreter Core']
creation = <Date 2002-09-25.18:15:01.000>
creator = 'gvanrossum'
dependencies = []
files = []
hgrepos = []
issue_num = 614555
keywords = []
message_count = 7.0
messages = ['12478', '12479', '12480', '12481', '12482', '55903', '59200']
nosy_count = 4.0
nosy_names = ['gvanrossum', 'tim.peters', 'brett.cannon', 'alexandre.vassalotti']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue614555'
versions = ['Python 2.6', 'Python 2.5']

@gvanrossum
Copy link
Member Author

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.

@gvanrossum gvanrossum self-assigned this Sep 25, 2002
@gvanrossum gvanrossum added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Sep 25, 2002
@gvanrossum gvanrossum self-assigned this Sep 25, 2002
@gvanrossum gvanrossum added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Sep 25, 2002
@gvanrossum
Copy link
Member Author

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.
"""

@gvanrossum
Copy link
Member Author

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).

@tim-one
Copy link
Member

tim-one commented Feb 14, 2003

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.

@gvanrossum
Copy link
Member Author

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.

@brettcannon
Copy link
Member

Classifying as an RFE since this is not critical (as shown by it not
happening since early 2003).

@brettcannon brettcannon added type-feature A feature request or enhancement labels Sep 13, 2007
@gvanrossum
Copy link
Member Author

I just don't see this happening. Possibly it's out of date. Lots of
things have changed in the pickle world since 2002.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants