From 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?
Python 3.15: features that didn't make the headlines
171–180 of 236 posts
Re: Python 3.15: features that didn't make the headlines
#172I 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.
Same, I’m not sure how Python survives this outside of machine learning. All of our services we were our are significantly faster and more reliable. We used Rust, it wasn’t hard to do
Re: Python 3.15: features that didn't make the headlines
#173Earlier quoted context omitted.
Static initializers in C++ - sometime ago I saw savings of some 400 ms (?) startup cost of initializing static strings from constants by moving it to some compile time thing.
Right; the issue is that this isn't happening at compile time in Python, because it's not getting compiled ahead-of-time. The equivalent would be if header files had imperative code that got executed at runtime in places where they're included. (To preempt potential pedantry: yes, I know that you can compile Python to bytecode ahead of time, but that's not really relevant to what's being discussed here because it doe…
What are those .pyc files for?
Re: Python 3.15: features that didn't make the headlines
#174Re: Python 3.15: features that didn't make the headlines
#175Earlier quoted context omitted.
> * Web sites: Typescript, or maybe Go. lol, no. Just no. Python is far superior for website backends unless perhaps you're running one of the top 20 websites in the world.
function Greeting({ name }: { name: string }) { return ( Hello, {name}! Welcome to my site. ); } That looks like HTML, but it's TypeScript. It gets compiled to actual HTML. Can any Python framework do that?? In Python, you'd typically write your logic in Python and your HTML in a separate Jinja2 template file — two languages, two files, context-switching. With Fresh + TSX, your logic and your markup live together in…
Yes, separating html out in jinja2 or whatever is far superior.
Re: Python 3.15: features that didn't make the headlines
#176I 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.
I'm still on the lookout for a comprehensive Django-like web framework for go. That would be an instant hit for me.
Re: Python 3.15: features that didn't make the headlines
#177Earlier quoted context omitted.
[flagged]
On most unix-likes all "imports" via shared libraries (e.g. in C / C++) are lazy by default.
I wouldn’t compare this in any way to Python’s lazy imports.
Re: Python 3.15: features that didn't make the headlines
#178Earlier quoted context omitted.
It's unrelated to the lazy keyword. Instead it's another feature related to error messages. The example: >> 'hello'.toUpperCase() Traceback (most recent call last): ... AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '.upper'?
I’ve often thought it would be funny if instead of an error message for stuff like this, a language could be designed to be “typo-insensitive”. If a method or function call is similar enough to an existing one or a common one from other languages, to just have it silently use that.
It would help the writer once, but impose a cost on all future readers for the lifetime of the code.
It's a bit like reading English with bits of German, French and Russian. All of sudden you have to know that Buch, livre and книга all mean the same thing.
Not to mention that there are often subtle differences in meaning between words that on the face of it seem equivalent (in both human and computer languages).
It could be a nice feature for an IDE though, to help someone learn a language.
Re: Python 3.15: features that didn't make the headlines
#179Earlier quoted context omitted.
Right; the issue is that this isn't happening at compile time in Python, because it's not getting compiled ahead-of-time. The equivalent would be if header files had imperative code that got executed at runtime in places where they're included. (To preempt potential pedantry: yes, I know that you can compile Python to bytecode ahead of time, but that's not really relevant to what's being discussed here because it doe…
> the issue is that this isn't happening at compile time in Python, because it's not getting compiled ahead-of-time What are those .pyc files for?
Re: Python 3.15: features that didn't make the headlines
#180I 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.
This is straightforward in the first instance, but how do you see maintenance of those projects going forward - especially adding more complex features ? I can see one way forward being to prototype them in python and convert.
We started in Python because of “the ecosystem”. It was a mistake. The amount of time we spend ripping out each dependency and pruning it to what we need is way higher than if we’d spent the month building out what we need. I miss compilers and LLMs will NOT generate config driven code or things that serde well. Everything has layers and layers of adapters by default and the domain model slowly erodes over time.