<- Back
Comments (119)
- kokadaFrom this example: lazy from typing import Iterator def stream_events(...) -> Iterator[str]: while True: yield blocking_get_event(...) events = stream_events(...) for event in events: consume(event) Do we finally have "lazy imports" in Python? I think I missed this change. Is this also something from Python 3.15 or earlier?
- xg15> Iterators, async functions and async iterators don't work well here because they have different semantics to standard functions. When you call them they return immediately with a generator object, coroutine function and async generator object respectively. So the decorator completes immediately as opposed to the entire lifecycle what it's wrapping.> This is an unfortunate problem I've encountered many times, and it's often a problem for normal decorators too. But this has changed in 3.15, now the ContextDecorator will check the type of the function it's wrapping and ensure that the decorator covers the entire lifespan.I very much like the idea of that change - but it also seems kind of dangerous, to do this with no "opt-in mechanism", as that quite subtly changes the behavior of existing usage sites.This is a bit of a "spacebar heating" situation, because someone would have to intentionally use a decorator in the old, broken way, but if someone actually did that, things may unexpectedly break.
- kwon-youngIt's nice that python 3.15 added Iterator synchronization primitives: https://docs.python.org/3.15/library/threading.html#iterator.... These will nicely complement my threaded-generator package which is doing just this but using a thread/process+generator+queue: https://pypi.org/project/threaded-generator/
- aniouI come to Python around version 1.5, painfully tired by debugging CGI scripts, created by wannabe perl-golfers. Unfortunately, I feel like Python is losing more and more of the zen that once tempted me...Lazy loading looks like a last nail in the coffin, where my love to Python was buried, although it was a long, tiresome process.
- JohnKemeny> I've left this one to the bonus section because I've never used set operations on Counters and I'm finding it extremely hard to think of a use case for xor specifically. But I do appreciate the devs adding it for completeness.Check out symmetric differencehttps://en.wikipedia.org/wiki/Symmetric_difference
- veqqThere's a good interview about Python internals and management, particularly in relation to free-threading: https://alexalejandre.com/programming/interview-with-ngoldba...
- jwineingerOne of the Counter examples is incorrect, tested on both 3.13 and 3.15.0a >>> from collections import Counter >>> c = Counter(a=3, b=1) >>> d = Counter(a=1, b=2) >>> c-d Counter({'a': 2})
- brianwawokI was so into Python for 10 years, was enjoyable to work in. But have deleted 100k+ lines this year already moving them to faster languages in a post AI codebot world. Mostly moving to go these days.
- drchaimOh, my beloved Python, for nearly 15 years I wrote you. I miss you, but I no longer do — it's not your fault, life has changed.
- syedMohib45Thread safe ittertors? really are we still on these topicslazy from typing import Iteratordef stream_events(...) -> Iterator[str]: while True: yield blocking_get_event(...)events = stream_events(...)for event in events: consume(event)
- sunshine-oI am not a python dev but have the utmost respect for the ecosystem.But damn, with all the supply chain attacks now in the news, could they just make a simple way (for non python insiders) to install python apps without fearing to be infected by a vermin with full access to my $HOME ...
- armanjfunny how we may have to wait even longer for llms to pick up this update in their pre-training
- anonundefined