[Python-Dev] More optimisation ideas
Steven D'Aprano
steve at pearwood.info
Fri Feb 5 00:05:45 EST 2016
On Thu, Feb 04, 2016 at 07:58:30PM -0500, Terry Reedy wrote:
> >>For folks that *do* know how to use the terminal:
> >>
> >>$ python3 -m inspect --details inspect
> >>Target: inspect
> >>Origin: /usr/lib64/python3.4/inspect.py
> >>Cached: /usr/lib64/python3.4/__pycache__/inspect.cpython-34.pyc
> >>Loader: <_frozen_importlib.SourceFileLoader object at 0x7f0d8d23d9b0>
> >>
> >>(And if they just want to *read* the source code, then leaving out
> >>"--details" prints the full module source, and would work even if the
> >>standard library were in a zip archive)
>
> This is completely inadequate as a replacement for loading source into
> an editor, even if just for reading.
[...]
I agree with Terry. The inspect trick Nick describes above is a great
feature to have, but it's not a substitute for opening the source in an
editor, not even on OSes where the command line tools are more powerful
than Windows' default tools.
[...]
> I agree that removing stdlib python source files by default is an poor
> idea. The disk space saved is trivial. So, for me, would be nearly all
> of the time saving.
I too would be very reluctant to remove the source files from Python by
default, but I have an alternative. I don't know if this is a ridiculous
idea or not, but now that the .pyc bytecode files are kept in a separate
__pycache__ directory, could we freeze that directory and leave the
source files available for reading?
(I'm not even sure if this suggestion makes sense, since I'm not really
sure what "freezing" the stdlib entails. Is it documented anywhere?)
--
Steve
More information about the Python-Dev
mailing list