Artwork

Konten disediakan oleh Michael Kennedy and Brian Okken. Semua konten podcast termasuk episode, grafik, dan deskripsi podcast diunggah dan disediakan langsung oleh Michael Kennedy and Brian Okken atau mitra platform podcast mereka. Jika Anda yakin seseorang menggunakan karya berhak cipta Anda tanpa izin, Anda dapat mengikuti proses yang diuraikan di sini https://id.player.fm/legal.
Player FM - Aplikasi Podcast
Offline dengan aplikasi Player FM !

#455 Gilded Python and Beyond

38:53
 
Bagikan
 

Manage episode 516035795 series 1305988
Konten disediakan oleh Michael Kennedy and Brian Okken. Semua konten podcast termasuk episode, grafik, dan deskripsi podcast diunggah dan disediakan langsung oleh Michael Kennedy and Brian Okken atau mitra platform podcast mereka. Jika Anda yakin seseorang menggunakan karya berhak cipta Anda tanpa izin, Anda dapat mengikuti proses yang diuraikan di sini https://id.player.fm/legal.
Topics covered in this episode:
Watch on YouTube
About the show

Sponsored by us! Support our work through:

Connect with the hosts

Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.

Michael #1: Cyclopts: A CLI library

Brian #2: The future of Python web services looks GIL-free

  • Giovanni Barillari
  • “Python 3.14 was released at the beginning of the month. This release was particularly interesting to me because of the improvements on the "free-threaded" variant of the interpreter.

    Specifically, the two major changes when compared to the free-threaded variant of Python 3.13 are:

    • Free-threaded support now reached phase II, meaning it's no longer considered experimental
    • The implementation is now completed, meaning that the workarounds introduced in Python 3.13 to make code sound without the GIL are now gone, and the free-threaded implementation now uses the adaptive interpreter as the GIL enabled variant. These facts, plus additional optimizations make the performance penalty now way better, moving from a 35% penalty to a 5-10% difference.”
  • Lots of benchmark data, both ASGI and WSGI
  • Lots of great thoughts in the “Final Thoughts” section, including
    • “On asynchronous protocols like ASGI, despite the fact the concurrency model doesn't change that much – we shift from one event loop per process, to one event loop per thread – just the fact we no longer need to scale memory allocations just to use more CPU is a massive improvement. ”
    • “… for everybody out there coding a web application in Python: simplifying the concurrency paradigms and the deployment process of such applications is a good thing.”
    • “… to me the future of Python web services looks GIL-free.”

Michael #3: Free-threaded GC

  • The free-threaded build of Python uses a different garbage collector implementation than the default GIL-enabled build.
  • The Default GC: In the standard CPython build, every object that supports garbage collection (like lists or dictionaries) is part of a per-interpreter, doubly-linked list. The list pointers are contained in a PyGC_Head structure.
  • The Free-Threaded GC: Takes a different approach. It scraps the PyGC_Head structure and the linked list entirely. Instead, it allocates these objects from a special memory heap managed by the "mimalloc" library. This allows the GC to find and iterate over all collectible objects using mimalloc's data structures, without needing to link them together manually.
  • The free-threaded GC does NOT support "generations”
  • By marking all objects reachable from these known roots, we can identify a large set of objects that are definitely alive and exclude them from the more expensive cycle-finding part of the GC process.
  • Overall speedup of the free-threaded GC collection is between 2 and 12 times faster than the 3.13 version.

Brian #4: Polite lazy imports for Python package maintainers

  • Will McGugan commented on a LI post by Bob Belderbos regarding lazy importing
  • “I'm excited about this PEP.

    I wrote a lazy loading mechanism for Textual's widgets. Without it, the entire widget library would be imported even if you needed just one widget. Having this as a core language feature would make me very happy.”

    https://github.com/Textualize/textual/blob/main/src/textual/widgets/__init__.py

  • Well, I was excited about Will’s example for how to, essentially, allow users of your package to import only the part they need, when they need it.

  • So I wrote up my thoughts and an explainer for how this works.
  • Special thanks to Trey Hunner’s Every dunder method in Python, which I referenced to understand the difference between __getattr__() and __getattribute__().

Extras

Brian:

  • Started writing a book on Test Driven Development.
    • Should have an announcement in a week or so.
    • I want to give folks access while I’m writing it, so I’ll be opening it up for early access as soon as I have 2-3 chapters ready to review. Sign up for the pythontest newsletter if you’d like to be informed right away when it’s ready. Or stay tuned here.

Michael:

Joke: You're absolutely right

  continue reading

464 episode

Artwork

#455 Gilded Python and Beyond

Python Bytes

1,333 subscribers

published

iconBagikan
 
Manage episode 516035795 series 1305988
Konten disediakan oleh Michael Kennedy and Brian Okken. Semua konten podcast termasuk episode, grafik, dan deskripsi podcast diunggah dan disediakan langsung oleh Michael Kennedy and Brian Okken atau mitra platform podcast mereka. Jika Anda yakin seseorang menggunakan karya berhak cipta Anda tanpa izin, Anda dapat mengikuti proses yang diuraikan di sini https://id.player.fm/legal.
Topics covered in this episode:
Watch on YouTube
About the show

Sponsored by us! Support our work through:

Connect with the hosts

Join us on YouTube at pythonbytes.fm/live to be part of the audience. Usually Monday at 10am PT. Older video versions available there too.

Finally, if you want an artisanal, hand-crafted digest of every week of the show notes in email form? Add your name and email to our friends of the show list, we'll never share it.

Michael #1: Cyclopts: A CLI library

Brian #2: The future of Python web services looks GIL-free

  • Giovanni Barillari
  • “Python 3.14 was released at the beginning of the month. This release was particularly interesting to me because of the improvements on the "free-threaded" variant of the interpreter.

    Specifically, the two major changes when compared to the free-threaded variant of Python 3.13 are:

    • Free-threaded support now reached phase II, meaning it's no longer considered experimental
    • The implementation is now completed, meaning that the workarounds introduced in Python 3.13 to make code sound without the GIL are now gone, and the free-threaded implementation now uses the adaptive interpreter as the GIL enabled variant. These facts, plus additional optimizations make the performance penalty now way better, moving from a 35% penalty to a 5-10% difference.”
  • Lots of benchmark data, both ASGI and WSGI
  • Lots of great thoughts in the “Final Thoughts” section, including
    • “On asynchronous protocols like ASGI, despite the fact the concurrency model doesn't change that much – we shift from one event loop per process, to one event loop per thread – just the fact we no longer need to scale memory allocations just to use more CPU is a massive improvement. ”
    • “… for everybody out there coding a web application in Python: simplifying the concurrency paradigms and the deployment process of such applications is a good thing.”
    • “… to me the future of Python web services looks GIL-free.”

Michael #3: Free-threaded GC

  • The free-threaded build of Python uses a different garbage collector implementation than the default GIL-enabled build.
  • The Default GC: In the standard CPython build, every object that supports garbage collection (like lists or dictionaries) is part of a per-interpreter, doubly-linked list. The list pointers are contained in a PyGC_Head structure.
  • The Free-Threaded GC: Takes a different approach. It scraps the PyGC_Head structure and the linked list entirely. Instead, it allocates these objects from a special memory heap managed by the "mimalloc" library. This allows the GC to find and iterate over all collectible objects using mimalloc's data structures, without needing to link them together manually.
  • The free-threaded GC does NOT support "generations”
  • By marking all objects reachable from these known roots, we can identify a large set of objects that are definitely alive and exclude them from the more expensive cycle-finding part of the GC process.
  • Overall speedup of the free-threaded GC collection is between 2 and 12 times faster than the 3.13 version.

Brian #4: Polite lazy imports for Python package maintainers

  • Will McGugan commented on a LI post by Bob Belderbos regarding lazy importing
  • “I'm excited about this PEP.

    I wrote a lazy loading mechanism for Textual's widgets. Without it, the entire widget library would be imported even if you needed just one widget. Having this as a core language feature would make me very happy.”

    https://github.com/Textualize/textual/blob/main/src/textual/widgets/__init__.py

  • Well, I was excited about Will’s example for how to, essentially, allow users of your package to import only the part they need, when they need it.

  • So I wrote up my thoughts and an explainer for how this works.
  • Special thanks to Trey Hunner’s Every dunder method in Python, which I referenced to understand the difference between __getattr__() and __getattribute__().

Extras

Brian:

  • Started writing a book on Test Driven Development.
    • Should have an announcement in a week or so.
    • I want to give folks access while I’m writing it, so I’ll be opening it up for early access as soon as I have 2-3 chapters ready to review. Sign up for the pythontest newsletter if you’d like to be informed right away when it’s ready. Or stay tuned here.

Michael:

Joke: You're absolutely right

  continue reading

464 episode

همه قسمت ها

×
 
Loading …

Selamat datang di Player FM!

Player FM memindai web untuk mencari podcast berkualitas tinggi untuk Anda nikmati saat ini. Ini adalah aplikasi podcast terbaik dan bekerja untuk Android, iPhone, dan web. Daftar untuk menyinkronkan langganan di seluruh perangkat.

 

Panduan Referensi Cepat

Dengarkan acara ini sambil menjelajah
Putar