classification
Title: zlib compressor/decompressor objects should support copy protocol
Type: enhancement Stage: resolved
Components: Extension Modules, Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Add support of copy protocol to zlib compressors and decompressors
View: 25007
Assigned To: Nosy List: josh.r, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-01-20 17:49 by josh.r, last changed 2016-01-20 18:08 by josh.r. This issue is now closed.

Messages (3)
msg258700 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2016-01-20 17:49
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).
msg258702 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-01-20 17:56
This is a duplicate of issue25007.
msg258705 - (view) Author: Josh Rosenberg (josh.r) * (Python triager) Date: 2016-01-20 18:08
Oops. Sorry. I swear I searched, but I can't figure out how I missed the obvious duplicate there.
History
Date User Action Args
2016-01-20 18:08:19josh.rsetmessages: + msg258705
2016-01-20 17:56:00serhiy.storchakasetstatus: open -> closed

superseder: Add support of copy protocol to zlib compressors and decompressors

nosy: + serhiy.storchaka
messages: + msg258702
resolution: duplicate
stage: resolved
2016-01-20 17:49:53josh.rsettype: enhancement
2016-01-20 17:49:43josh.rcreate