Skip to content

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

Closed

Description

@serhiy-storchaka
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']

    Activity

    1. serhiy-storchaka commented on Nov 15, 2017

      @serhiy-storchaka
      MemberAuthor

      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.

    2. added
      stdlib
      type-feature
      on Nov 15, 2017
    3. serhiy-storchaka commented on Nov 16, 2017

      @serhiy-storchaka
      MemberAuthor

      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

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Labels

    3.7 (EOL)stdlibtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions