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

zlib compressor/decompressor objects should support copy protocol #70354

Closed
MojoVampire mannequin opened this issue Jan 20, 2016 · 3 comments
Closed

zlib compressor/decompressor objects should support copy protocol #70354

MojoVampire mannequin opened this issue Jan 20, 2016 · 3 comments
Labels
extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@MojoVampire
Copy link
Mannequin

MojoVampire mannequin commented Jan 20, 2016

BPO 26166
Nosy @serhiy-storchaka, @MojoVampire
Superseder
  • bpo-25007: Add support of copy protocol to zlib compressors and decompressors
  • 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 = None
    closed_at = <Date 2016-01-20.17:56:00.986>
    created_at = <Date 2016-01-20.17:49:43.355>
    labels = ['extension-modules', 'type-feature', 'library']
    title = 'zlib compressor/decompressor objects should support copy protocol'
    updated_at = <Date 2016-01-20.18:08:19.168>
    user = 'https://github.com/MojoVampire'

    bugs.python.org fields:

    activity = <Date 2016-01-20.18:08:19.168>
    actor = 'josh.r'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-01-20.17:56:00.986>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules', 'Library (Lib)']
    creation = <Date 2016-01-20.17:49:43.355>
    creator = 'josh.r'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 26166
    keywords = []
    message_count = 3.0
    messages = ['258700', '258702', '258705']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'josh.r']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '25007'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue26166'
    versions = ['Python 3.5', 'Python 3.6']

    @MojoVampire
    Copy link
    Mannequin Author

    MojoVampire mannequin commented Jan 20, 2016

    zlib.compressobj and zlib.decompressobj objects (actually zlib.Compress and zlib.Decompress, the other names are the function constructors I guess?) have a .copy() method, but don't implement __copy__ or __deepcopy__. This leads to the mildly silly result that a copyable object can't be copied using the common copy protocol.

    I see two solutions:

    1. Implement __copy__ and __deepcopy__ directly for the zlib objects
    2. Have the copy module include them in _copy_dispatch mapped to the existing _copy_with_copy_method (and use a similar approach for _deepcopy_dispatch, since AFAICT this isn't a case where deep copying differs from shallow copying)

    The former makes for more C code in CPython, and would require matching updates in the zlib used by all alternate CPython interpreters, but is probably faster and introduces no new cross-module dependencies.

    The latter would make zlib an import dependency of copy (or vice versa, if zlib messed with copy's internals on import), but involves only a trivial amount of new Python code and wouldn't require any changes by alternate Python implementations that used the core copy module (when they update to the new copy, they get the support for free).

    @MojoVampire MojoVampire mannequin added extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jan 20, 2016
    @serhiy-storchaka
    Copy link
    Member

    This is a duplicate of bpo-25007.

    @MojoVampire
    Copy link
    Mannequin Author

    MojoVampire mannequin commented Jan 20, 2016

    Oops. Sorry. I swear I searched, but I can't figure out how I missed the obvious duplicate there.

    @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
    extension-modules C modules in the Modules dir 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