[New-bugs-announce] [issue26166] zlib compressor/decompressor objects should support copy protocol

Josh Rosenberg report at bugs.python.org
Wed Jan 20 12:49:43 EST 2016


New submission from Josh Rosenberg:

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).

----------
components: Extension Modules, Library (Lib)
messages: 258700
nosy: josh.r
priority: normal
severity: normal
status: open
title: zlib compressor/decompressor objects should support copy protocol
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26166>
_______________________________________


More information about the New-bugs-announce mailing list