Mailinglist Archive: opensuse-factory (381 mails)

< Previous Next >
Re: [opensuse-factory] Re: [opensuse-packaging] Proposal to remove pyc/pyo from Python on TW
  • From: Brüns, Stefan <Stefan.Bruens@xxxxxxxxxxxxxx>
  • Date: Fri, 5 Oct 2018 00:24:34 +0000
  • Message-id: <2829011.AQOFaJkinR@sbruens-linux.lcs.intern>
On Donnerstag, 4. Oktober 2018 19:05:16 CEST Stephan Kulow wrote:
Am 04.10.18 um 18:39 schrieb Jan Engelhardt:
On Thursday 2018-10-04 16:52, Alberto Planas Dominguez wrote:
I also estimated some gains for different scenarios. For example in a
normal TW installation:

* Python 2.7 + 3.6

- pyc/pyc: 127M total
- py: 109M total

* Python 3.6 only

- pyc/pyc: 91M total
- py: 70M total

Or one could remove py and keep pyc/pyo.
That's basically how GNU C C++ & Fortran, Erlang, ocaml, .. all work ;-)

Would that work? That sounds like the perfect solution to me :)

Not in a trivial way. There is a reason the files in __pycache__ have the
{implementation}.opt-{optimization} infix, the bytecode is implementation
defined.

If you want python to use only the bytecode, you have to place it in the
source directory (i.e. on level above the __pycache__ directory), and remove
the infix from the name. The .pyc file can be a symlink into the __pycache__
directory. E.g.:

---
-+ foo.py
+ foo.pyc -> __pycache__/foo.cpython-36.pyc
+ __pycache__
-+ foo.cpython-36.pyc
+ foo.cpython-36.opt-1.pyc
+ foo.cpython-36.opt-2.pyc
__

Then you have to split this into a least 3 packages
- source
- bytecode with default optimization level + symlink, all
- bytecode for other optimization levels

To add some more fun, the bytecode files for all or at least some optimization
levels may be bitidentical, which currently is leveraged by hardlinking the
files. That is no longer possible when you split the bytecode files.

You also have to decide on your default optimization level. As opt-1 and opt-2
remove any assert's, using e.g. opt-1 as default level may change the runtime
behaviour of you code.

Kind regards,

Stefan--
To unsubscribe, e-mail: opensuse-factory+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-factory+owner@xxxxxxxxxxxx

< Previous Next >