This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: longs should be pickled in hexadecimal
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: fredrik_j, rhettinger, tim.peters
Priority: normal Keywords:

Created on 2005-05-26 17:58 by fredrik_j, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg25415 - (view) Author: Fredrik Johansson (fredrik_j) Date: 2005-05-26 17:58
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.
msg25416 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-05-26 18:17
Logged In: YES 
user_id=80475

Rather than introduce a backwards incompatible change, just
use binary pickles:  pickle.dumps(123**100001, 2).
msg25417 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-05-26 18:57
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.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42015
2005-05-26 17:58:34fredrik_jcreate