[ python-Bugs-1209324 ] longs should be pickled in hexadecimal

SourceForge.net noreply at sourceforge.net
Thu May 26 20:57:05 CEST 2005


Bugs item #1209324, was opened at 2005-05-26 13:58
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1209324&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Closed
Resolution: Wont Fix
Priority: 5
Submitted By: Fredrik Johansson (fredrik_j)
Assigned to: Nobody/Anonymous (nobody)
Summary: longs should be pickled in hexadecimal

Initial Comment:
Longs are currently pickled to their decimal
representation. However, converting a very large number
represented in a binary base (used by Python longs) to
decimal is inefficient.

For example, the operation pickle.dumps(123**100001)
takes 50 seconds on my computer. The hexadecimal
representation of the same number, via hex(), can be
computed in an instant.

The hexadecimal representation also has the benefit of
being more concise.

I therefore suggest that the pickle format is changed
so that pickled longs are represented in hexadecimal.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2005-05-26 14:57

Message:
Logged In: YES 
user_id=31435

More precisely, use pickle protocol 2 (or higher, although 2 is 
as high is it goes so far).  In pickle protocol 1 (which used to 
be called "binary"), and in protocol 0 (which used to be 
called "text") pickling and unpickling longs were still 
quadratic-time operations.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2005-05-26 14:17

Message:
Logged In: YES 
user_id=80475

Rather than introduce a backwards incompatible change, just
use binary pickles:  pickle.dumps(123**100001, 2).


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1209324&group_id=5470


More information about the Python-bugs-list mailing list