This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Expand zipimport to support bzip2 and lzma
Type: Stage:
Components: Versions: Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Expand zipimport to include other compression methods
View: 17004
Assigned To: Nosy List: brett.cannon, dstufft, eric.snow, ncoghlan, r.david.murray, serhiy.storchaka
Priority: normal Keywords:

Created on 2014-06-13 18:29 by dstufft, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (12)
msg220477 - (view) Author: Donald Stufft (dstufft) * (Python committer) Date: 2014-06-13 18:29
Since Python 3.3 the zipfile module has support bzip2 and lzma compression, however the zipimporter does not support these. It would be awesome if zipimport did support them.
msg220481 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-06-13 19:02
See also issue 17004 and issue 5950.
msg220518 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-06-14 01:18
Zipimporter doesn't use zipfile (the former is written in C), so it unfortunately doesn't fall through for support.
msg220527 - (view) Author: Donald Stufft (dstufft) * (Python committer) Date: 2014-06-14 02:39
Right, but it could still have support for those things implemented yea?
msg220528 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2014-06-14 02:48
On Jun 13, 2014 7:39 PM, "Donald Stufft" <report@bugs.python.org> wrote:
>
>
> Donald Stufft added the comment:
>
> Right, but it could still have support for those things implemented yea?

Yes, it's just zipimport has a history of being difficult to maintain.

>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue21751>
> _______________________________________
msg220538 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-06-14 08:56
As shown in msg180323, using lzma compression for typical *.py and *.pyc produces 8% less zip file, but reading from it is 2.5 times slower. The bzip2 compression is even worse. So there is no large benefit in supporting other compression methods.
msg220569 - (view) Author: Donald Stufft (dstufft) * (Python committer) Date: 2014-06-14 17:12
I disagree that there is no large benefit. Python files aren't the only files that could exist inside of a zip file. Supporting LZMA import (or bz2) would make it easier to have LZMA or bzip2 wheels in the future without losing the ability to import them.
msg220572 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-06-14 17:42
For non-Python files you don't need support of bzip2 or lzma compression in 
zipimport. Use zipfile which supports advanced compression.
msg220573 - (view) Author: Donald Stufft (dstufft) * (Python committer) Date: 2014-06-14 17:46
I'm not sure what that statement means. There is package data that sits alongside python files. These cannot use anything but DEFLATED because zipimport doesn't support it.
msg220590 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2014-06-14 22:20
related: issue #17630
msg220599 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-06-15 00:06
Another use case is more aggressively shrinking the bundled copy of pip. We
don't really care about speed of execution there (since we only run it
directly once at install time to do the bootstrapping), but we do care
about the impact on the installer size.

However, that's a fairly specialised case - for wheel 2.0 in general, we
can consider dropping the "always usable as a sys.path entry" behaviour and
not need to worry about the constraints of zipimport (which has indeed
exhibited unfortunate "we touch it, we break it" behaviour in recent
releases, due to the vagaries of zip implementations on various platforms).

A more general archive importer written in Python could also be useful -
there's no requirement that all archive formats be handled by the existing
meta importer. Putting such an importer *after* the existing zip importer
in the metapath would minimise any risk of backwards incompatibility
issues, and allow it to initially be created as a third party module on
PyPI.
msg220617 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-06-15 07:41
You can use deflate for Python files and advanced compression methods for large well-compressable package data.
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65950
2014-06-15 07:41:20serhiy.storchakasetmessages: + msg220617
2014-06-15 00:06:42ncoghlansetmessages: + msg220599
2014-06-14 22:20:32eric.snowsetmessages: + msg220590
2014-06-14 17:46:07dstufftsetmessages: + msg220573
2014-06-14 17:42:02serhiy.storchakasetmessages: + msg220572
2014-06-14 17:12:28dstufftsetmessages: + msg220569
2014-06-14 08:56:02serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg220538
2014-06-14 08:47:51serhiy.storchakasetstatus: open -> closed
superseder: Expand zipimport to include other compression methods
resolution: duplicate
2014-06-14 02:48:00brett.cannonsetmessages: + msg220528
2014-06-14 02:39:31dstufftsetmessages: + msg220527
2014-06-14 01:18:46brett.cannonsetmessages: + msg220518
2014-06-13 19:02:09r.david.murraysetnosy: + r.david.murray
messages: + msg220481
2014-06-13 18:29:15dstufftcreate