[GRASS-dev] Compilation/Distribution of *.pyc files
Panagiotis Mavrogiorgos
pmav99 at gmail.com
Tue Mar 5 16:56:49 PST 2019
>
> $ cat include/Make/Python.make
> PY_SOURCES := $(wildcard *.py)
> %.pyc: %.py
> $(PYTHON) -t -m py_compile $<
The make command explicitly compiles the *.py files to *.pyc and copies
them to the dist directory. I haven't tested the packaging code but I guess
that they might get included in the packages too.
Just for the record, on linux x64 + Python 3:
du -ch ./dist.x86_64-pc-linux-gnu | tail -n1
93M ./
$ find ./dist.x86_64-pc-linux-gnu -name *.pyc -exec du -ch {} + | tail -n1
6.6M total
$ find ./dist.x86_64-pc-linux-gnu -name *.py -exec du -ch {} + | tail -n1
9.7M total
Is there a reason why this is happening? AFAIK distributing just the *.py
files is usually enough since *.pyc files get created on first import (if
the user has write permissions; for more info here
<https://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm>)
The other downside, and the real reason I looked into this, is that on my
laptop I need ~5 secs to run make on lib/python (on Python 3; Python 2 is
faster). Not too big, but big enough for an interpreted language like
Python. And smaller compilation times help you get into and stay in the flow
<https://www.joelonsoftware.com/2001/02/12/human-task-switches-considered-harmful/>
:P
PS. Not a real biggie, but I am just curious.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20190306/c5a3d5eb/attachment.html>
More information about the grass-dev
mailing list