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

Pickle 32-bit integers with protocol 0 as INT instead of LONG #76218

Closed
serhiy-storchaka opened this issue Nov 15, 2017 · 2 comments
Closed

Pickle 32-bit integers with protocol 0 as INT instead of LONG #76218

serhiy-storchaka opened this issue Nov 15, 2017 · 2 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

BPO 32037
Nosy @avassalotti, @serhiy-storchaka
PRs
  • bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. #4407
  • 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/serhiy-storchaka'
    closed_at = <Date 2017-11-16.07:45:07.353>
    created_at = <Date 2017-11-15.16:59:49.683>
    labels = ['3.7', 'type-feature', 'library']
    title = 'Pickle 32-bit integers with protocol 0 as INT instead of LONG'
    updated_at = <Date 2017-11-16.07:45:07.352>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2017-11-16.07:45:07.352>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-11-16.07:45:07.353>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2017-11-15.16:59:49.683>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32037
    keywords = ['patch']
    message_count = 2.0
    messages = ['306285', '306342']
    nosy_count = 2.0
    nosy_names = ['alexandre.vassalotti', 'serhiy.storchaka']
    pr_nums = ['4407']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32037'
    versions = ['Python 3.7']

    @serhiy-storchaka
    Copy link
    Member Author

    In Python 3 different opcodes are used for pickling integers with protocol 1 and higher. But pickling with protocol 0 always uses the LONG opcode. In Python all such integers are unpickled to the long instances.

    Proposed PR makes integers that fit in a signed 32-bit integer be pickled with the INT opcode. This will decrease the size of a pickle (minus one byte 'L' per integer), speeds up pickling and unpickling, and makes these integers be unpickled to int instances in Python 2, that will save a memory.

    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Nov 15, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this Nov 15, 2017
    @serhiy-storchaka serhiy-storchaka added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Nov 15, 2017
    @serhiy-storchaka
    Copy link
    Member Author

    New changeset 3daaafb by Serhiy Storchaka in branch 'master':
    bpo-32037: Use the INT opcode for 32-bit integers in protocol 0 pickles. (bpo-4407)
    3daaafb

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant