[Python-ideas] Move optional data out of pyc files

Antoine Pitrou solipsis at pitrou.net
Tue Apr 10 14:25:27 EDT 2018


On Tue, 10 Apr 2018 11:13:01 -0700
Ethan Furman <ethan at stoneleaf.us> wrote:
> On 04/10/2018 10:54 AM, Zachary Ware wrote:
> > On Tue, Apr 10, 2018 at 12:38 PM, Chris Angelico <rosuav at gmail.com> wrote:  
> >> A deployed Python distribution generally has .pyc files for all of the
> >> standard library. I don't think people want to lose the ability to
> >> call help(), and unless I'm misunderstanding, that requires
> >> docstrings. So this will mean twice as many files and twice as many
> >> file-open calls to import from the standard library. What will be the
> >> impact on startup time?  
> >
> > What about instead of separate files turning the single file into a
> > pseudo-zip file containing all of the proposed files, and provide a
> > simple tool for removing whatever parts you don't want?  
> 
> -O and -OO already do some trimming; perhaps going that route instead of having multiple files would be better.

"python -O" and "python -OO" *do* generate different pyc files.
If you want to trim docstrings with those options, you need to
regenerate pyc files for all your dependencies (including third-party
libraries and standard library modules).

Serhiy's proposal allows "-O" and "-OO" to work without needing a
custom bytecode generation step.

Regard

Antoine.




More information about the Python-ideas mailing list