Subject: [bug#47251] [core-updates] [patch] gnu: python: Enable optimizations.

From: Ludovic Courtès <[email-masked]>
Date: Sun, 06 Jun 2021 14:34:31 +0200

Hi,

Julien Lepiller <[email-masked]> skribis:

> Right, this is a good idea. I wrote the attached patches to: enable
> optimizations, prevent building and installing the static library and
> to install idle to a separate output, as it is not required in general.
>
> With the patch from https://issues.guix.gnu.org/47214, python 3.9 on
> coreupdates is ~1.7x faster than python 3.8 on master, and is ~25MB
> smaller than 3.8 on master (I haven't measured the speedup for python2,
> and it is ~10MB smaller with these changes than on master).

Yay!

> From 0c45d6e82a5f4d140840aef6b0de321122b6c4df Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <[email-masked]>
> Date: Thu, 18 Mar 2021 23:41:40 +0100
> Subject: [PATCH 2/4] gnu: python: Enable optimizations.
>
> As a result, python execution time of scripts is decreased by 6 to 40%.
>
> gnu/packages/python (python-2.7)[arguments]: Add configure and make flags to
> optimize the resulting python.

[...]

> +             "CFLAGS=-fno-semantic-interposition"
>               (string-append "LDFLAGS=-Wl,-rpath="
> -                            (assoc-ref %outputs "out") "/lib"))
> +                            (assoc-ref %outputs "out") "/lib"
> +                            " -fno-semantic-interposition"))

Could you add a comment for ‘-fno-semantic-interposition’?  Also, please
make sure that setting CFLAGS does not override useful defaults (for
Autoconf-based build systems, CFLAGS defaults to ‘-O2 -g’ and overriding
it means you lost both -O2 and -g; if we lose ‘-g’, ‘--with-debug-info’
won’t have any effect).

> From 1faeb01becd558f0f4eec16ff32df9dbf1adda7f Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <[email-masked]>
> Date: Thu, 3 Jun 2021 22:10:09 +0200
> Subject: [PATCH 3/4] gnu: python: Do not install static libraries.
>
> This is something Fedora already does since 2010, so it should be safe,
> and saves a lot of space.
>
> * gnu/packages/patches/python-2.7-no-static-lib.patch: New file.
> * gnu/packages/patches/python-3-no-static-lib.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Add them.
> * gnu/packages/python.scm (python-2.7, python-3): Use them.

LGTM.

> From c650ac48be47b373c6c8c0b3495f30d9fe21e68b Mon Sep 17 00:00:00 2001
> From: Julien Lepiller <[email-masked]>
> Date: Thu, 3 Jun 2021 22:14:14 +0200
> Subject: [PATCH 4/4] gnu: python: Move idle to a separate output.
>
> idle is a programming environment that is not useful for building
> packages, but it is still useful for end users. This saves 5MB in the
> default output.
>
> * gnu/packages/python.scm (python-2.7)[outputs]: Add `idle'.
> [arguments]: Move idle files in the new output.
> (wrap-python): Do not wrap idle since it is in a different output.

Good idea, LGTM.

Thank you!

Ludo’.