Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by Evgeniy »

At the moment, Python 3.11 is being prepared for release, and it has some acceleration.

https://docs.python.org/3/whatsnew/3.11.html
Python 3.11 is between 10-60% faster than Python 3.10. On average, we measured a 1.25x speedup on the standard benchmark suite. See Faster CPython for details.
Future speed up plains:

https://github.com/markshannon/faster-c ... er/plan.md

Currently, FreeCAD 0.20.1 uses the 3.8.10 Python version:

Code: Select all

Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type 'help', 'copyright', 'credits' or 'license' for more information.
Are there plans to integrate faster Python versions into future FreeCAD Release?
Maybe I'm rushing things, of course, but this is for the developers' note.
Last edited by Kunda1 on Wed Nov 30, 2022 12:42 pm, edited 1 time in total.
Reason: updated topic
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by Kunda1 »

I believe chennes posted somewhere the 3rd party dependency goals for the v0.21 or v1.0 release. But in the meantime, we could also add IFDEF blocks to the code to support Python3.11 like we have in the past with other updated versions of python
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by obelisk79 »

I think Kunda's proposal is probably the best. Based on my observations, the packaged dependency versions are based on what is available in the latest ubuntu-lts repositories. I could be wrong on that, but it's a logical and sane approach for a multi-platform project such as this.
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by Evgeniy »

Of course, I don't know the specifics of building the FreeCAD kernel, but if Python scripts/tools/workbenches work faster or even get a little closer in speed to C++, it will be great.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by adrianinsaval »

There where some commits for python11 compatibility already IIRC (it might already be fully compatible?), note that freeecad will likely aim to support python 3.11 once it is actually released, also note that only windows releases (and some older distro packages, but those are completely outside of our control) use python 3.8, the macos and linux appimage releases are already using 3.10 and will likely eventually move to 3.11.

There's also a windows conda package that uses 3.10, 3.8 is used on the installer only because it's the last version supported by windows 7 and apparently there's a bunch of people still using that (and even with that it can be problematic if the win7 install is not fully updated)
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by Evgeniy »

I think you are talking about these builds with Python 3.10 inside:
https://github.com/FreeCAD/FreeCAD-Bund ... kly-builds
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by adrianinsaval »

yes, and work is already underway to get 3.11 builds: https://github.com/conda-forge/freecad- ... ck/pull/78, the windows installer for the next release will likely still be 3.8 but there's probably going to be a conda 3.11 build too.
While there's probably going to be some speeds up, I highly doubt that this would be noticeable in everyday use.
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by Evgeniy »

I downloaded 0.21.0 build with Python 3.10, of course I did not do special perfomance tests, but it works faster according to sensations.
adrianinsaval wrote: Wed Nov 30, 2022 7:00 pm There's also a windows conda package that uses 3.10, 3.8 is used on the installer only because it's the last version supported by windows 7 and apparently there's a bunch of people still using that (and even with that it can be problematic if the win7 install is not fully updated)
I'm not against backward compatibility. If required, can release two assemblies for compatibility.
User avatar
waebbl
Posts: 200
Joined: Thu Aug 16, 2018 3:12 pm

Re: Discussion: Python 3.11 Integration to FreeCAD (apparently there is a performance boost)

Post by waebbl »

I was trying to add py311 compatibility for the Gentoo 0.20.2 package. FreeCAD itself builds with Python 3.11, but the runtime testing framework won't even start, so I decided against adding this option for the first 0.20.2 release.
The error I get is like

Code: Select all

>>> Test phase: media-gfx/freecad-0.20.2
unknown option --run-test
usage: ./bin/FreeCADCmd [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.
Program received signal SIGSEGV, Segmentation fault.
#0  /usr/lib64/libc.so.6(+0x38a10) [0x7f524ba55a10]
#1  /usr/lib64/libc.so.6(+0x15d1f9) [0x7f524bb7a1f9]
#2  /usr/lib64/libpython3.11.so.1.0(+0x29ad77) [0x7f524b49ad77]
#3  /usr/lib64/libpython3.11.so.1.0(Py_EncodeLocale+0x49) [0x7f524b49b989]
#4  ./bin/FreeCADCmd(+0x350d) [0x55fc5fb0d50d]
#5  /usr/lib64/libc.so.6(+0x234a4) [0x7f524ba404a4]
#6  /usr/lib64/libc.so.6(__libc_start_main+0x94) [0x7f524ba40574]
#7  ./bin/FreeCADCmd(+0x3a61) [0x55fc5fb0da61]
>>> Completed testing media-gfx/freecad-0.20.2
which looks, without having done any research first, like python is being called without a version qualifier, i.e. like python and not python3.11, but could also be related to FC being not yet ready for Python 3.11.
Post Reply