Trying to extend my pi3-based #HomeAssistant with a #Python script for some local data processing & control.
I need CPU & memory use to stay low, so looking at making some C extension functions for the heavier bits.
I often do those with the Python C API, but this time trying out #Cython again.
Last time I used it was 10 years ago. Now I noticed it recently released v3.0.0 with a new pure python syntax based on type annotations and decorators - quite interesting
#homeassistant #python #cython
Eksperymentuję z nowym testem QA dla ebuildów #Gentoo dla paczek Pythona. Udało mi się zlokalizować kilka paczek, w których nie testowaliśmy zainstalowanych rozszerzeń w języku C, bo katalog źródłowy wpierniczał się, #Python "widział" tylko źródła i testował wersję w czystym Pythonie.
Po poprawieniu tych błędów, okazało się, że dwie paczki były oznaczone jako zgodne z Pythonem 3.12, podczas gdy ich rozszerzenia się sypały. Dwie kolejne miały padające testy przy korzystaniu z rozszerzeń C na wszystkich wersjach Pythona.
Przy okazji, dodałem brakujące ograniczenie do #Cython < 3 przy kilkunastu paczkach, a w dwóch uczyniłem rozszerzenia C opcjonalnymi.
Teraz jeszcze muszę poprawić ten test QA, żeby pozbyć się fałszywie dodatnich wyników, które występują wówczas, gdy katalog źródłowy zawiera pliki .c — których oczywiście nie ma w zainstalowanej paczce.
Miałem pisać o fajnych rzeczach, a zamiast tego ciągniemy temat #PyYAML. Autorzy wciąż odrzucają poprawki zgodności z #Cython 3. Jest już dosyć jasne, że dystrybucje będą musiały męczyć się z własnymi łatkami jeszcze przez długi czas. Wzdych.
Sytuacja z #PyYAML-em jest rozwojowa. Wiara coraz bardziej stara się niezależnie naprawiać swoje zabawki. Najwyraźniej pip pozwala na odgórne ograniczenie akceptowalnych wersji pakietów, ale to również nie rozwiązuje problemu w pełni.
Mam dwie myśli:
1. *W końcu* nie tylko my w #Gentoo mamy problem sprzecznych oczekiwań różnych paczek (czyt. nie tylko nam się wszystko sypie, bo potrzeba dwóch różnych wersji Cythona jednocześnie).
2. Biorąc pod uwagę, że problem znany był półtora roku, i autorzy PyYAML-a nie zrobili nic, żeby go rozwiązać… czy naprawdę sądzicie, że dalsze używanie tej paczki to dobry pomysł? Albo szerzej mówiąc, czy użycie YAML-a to dobry pomysł, Norway?
https://discuss.python.org/t/no-way-to-pin-build-dependencies/29833
#cython #python #gentoo #pyyaml
A pamiętacie jak #PyYAML ignorował problem zgodności z Cythonem 3 przez półtora roku? No więc, #Cython 3 wyszedł dzisiaj i zgłoszenie błędu eksplodowało, kiedy pierdyliard potoków zaczęło się sypać.
#Cython 3.0 is (almost) out !
(binaries are being deployed right now, so it should be available in a couple hours)
https://github.com/cython/cython/releases/tag/3.0.0
This is exciting news for our ecosystem because it's the first stable version able to *not* generate deprecated C-API #numpy code. When it's widely adopted, Numpy devs will finally be able to move forward with performance optimisations that were not possible without breaking everyone's favourite package !
People have told me to replace the most critical #Python codes with Cython, and it would increase my app’s performance 12,000 times. I did it, and indeed it increased the performance by about 12,000. times. So I asked myself: What if I replace EVERY SINGLE Python code with Cython? So I did it, and the performance was 35,000 faster than the original code. That’s why I recommend #Cython.
This year is very intensive in terms of migrations for scientific Python maintainers:
- a new #CPython (3.12) in October
- a major version of #Cython (3.0) announced for this summer
- a major version of #Numpy (2.0) scheduled for the end of the year
All of which will require careful testing and probably take some time to propagate through the giant mess that are dependency trees in scientific #Python 😵💫
#cpython #cython #numpy #python
Been using #VSCode for a week at work and it's quite good. Might use it over #PyCharm at some point.
Started using PyCharm when I worked on PsychXR for Oculus, mainly because of the #Cython support. Excellent software, but feels like overkill these days TBH.
Side note, #Geany takes the prize for my most used IDE. Used it exclusively for software development between 2006-2018, longer than anything else.
#vscode #pycharm #cython #geany #programming #editor
Cython is a language that is a superset of Python, and compiles to C, allowing for performance boosts. It can be used to transcend the native limitations of Python without sacrificing its convenience and ease. https://www.infoworld.com/article/3250299/what-is-cython-python-at-the-speed-of-c.html#tk.rss_all #Cython #PerformanceBoost #Python
#cython #performanceboost #python
Thinking of dipping my toe into the #cython world of #Python today. I need something like a QTimer from Qt/PyQt/PySide, where I can run a function in the background at a set interval.
Need to be able to run a function at up to maybe 300 Hz. I have this case already working w/ a QTimer, but would like to do it without the event loop design constraint (and giant dependency) of Qt.
You know you're doing something cursed when you're compiling your own version of #Python to get the static libraries because they're removed from the Arch package.
I'm playing with #Cython, trying to get it to produce a standalone executable with the --embed option.
Sidenote: Anyone got suggestions for a good build system for a Python game that needs to be compiled to a standalone distribution (single folder or single binary), using either Cython or #Nuitka, that I could get working cross-platform?
The basic operation is pretty straightforward, from a mathematical standpoint, but getting this right everywhere, including the edges of the image, was quite challenging.
In order to put this together, I learned a lot !
The hot loops are done in #Cython, which was new to me, and designing an extensible framework that I won't need to come back to every time someone (me) comes up with new exotic boundary conditions required careful thinking.
This might be worse
RT @sahajsarup@twitter.com
What I assumed #Cython would look like
🐦🔗: https://twitter.com/sahajsarup/status/1560464929135955968
My talk at #PyConUS2022 on #Python performance optimization with #Cython (including packaging tips and library integration with @Blender@twitter.com) is now on Youtube!
👉https://www.youtube.com/watch?v=TE3M3XfwSN4
You can also see the the slide deck here:
https://github.com/m-clare/pymaxion/tree/main/presentations 1/4
#pyladies #womenintech
#PyConUS2022 #python #cython #pyladies #womenintech
Today’s the day😱! @pycon@twitter.com I’ll be talking at 2:30 about building #Cython packages and how to integrate a geometric constraint solver into @Blender@twitter.com. There will also be gifs @pyladies@twitter.com #PyConUS2022 #PyCon2022 https://t.co/VAwZPpAJk9
#cython #PyConUS2022 #PyCon2022