On Thu, 2020-01-16 at 10:27 +0100, Miro HronĨok wrote:
On 15. 01. 20 23:11, Victor Stinner wrote:
> > Solution 4: ZIP the entire standard library
> > (...)
> > Nevertheless, this might (in theory) **save 17.8 MiB / 47 %**.
>
> It's my favorite option. Almost 50% smaller is quite good! It would
> be
> very efficient to have such disk space gain!
>
> Using a ZIP file for the stdlib is commonly suggested solution when
> the slow Python startup time is discussed. Python does tons of
> system
> calls to load stdlib modules at startup: many stat() and open()
> calls.
> Having a single large ZIP file allows to do more work in pure
> userland.
>
> This solution is well supported by unmodified Python: it's part of
> the
> default sys.path search path:
>
> $ python3
> Python 3.7.6 (default, Dec 19 2019, 22:52:49)
> > > > import sys; sys.path
> ['', '/usr/lib64/python37.zip', ...]
>
> It's the second item of sys.path ;-)
It is, yet modules in the standard library still do read files next
to __file__
and will blow up when zipped. That makes me believe we can put some
modules into
/usr/lib64/python38.zip, but not the entire unmodified stdlib at this
moment. We
can certainly work towards this goal if we get somebody to drive it.
> I'm ok to discourage users to override *system files* by modifying
> them as root. It's too easy to mess up your system this way.
Discouraging users is hard. We discourage users to use sudo pip and
yet **you**
still do it Victor :D
> It is easy to extract the ZIP file in your home directory, hack
> some
> files and use PYTHONPATH environment variable to force loading your
> modified stdlib.
>
> * faster startup
> * less disk space
> * harder to mess up your system
>
> Where are drawbacks by the way? ;-)
Behind the corner.
If a traceback for an exception includes files from the .zip, can the
traceback-printing machinery still print the pertinent lines of source?
Dave