Live data from Hacker News

Python 3.15: features that didn't make the headlines

blog.changs.co.uk

171–180 of 236 posts

Re: Python 3.15: features that didn't make the headlines

#171
post #4

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 has had lazy imports from like day one, where you could have an import statement in a function, and the library won't be imported until that function is hit.

Re: Python 3.15: features that didn't make the headlines

#172

I 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

[dead]

Re: Python 3.15: features that didn't make the headlines

#173
post #134

Earlier 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…

> 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

#175

Earlier 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…

That's the ugliest spaghetti i've seen in a long time. Why would anybody want to do that to themselves or their co-coders?

Yes, separating html out in jinja2 or whatever is far superior.

Re: Python 3.15: features that didn't make the headlines

#176
post #59

I 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.

Try gofiber, i love python, i eat thanks to python but Django...... Gofiber isnt perfect, but it's really great

Re: Python 3.15: features that didn't make the headlines

#177
post #13

Earlier quoted context omitted.

[flagged]

On most unix-likes all "imports" via shared libraries (e.g. in C / C++) are lazy by default.

Eh, resolving object symbols is something done at runtime. #include absolutely is eager.

I wouldn’t compare this in any way to Python’s lazy imports.

Re: Python 3.15: features that didn't make the headlines

#178
post #93

Earlier 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.

Funny, yes, but IMO a terrible idea. :)

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

#179
post #134

Earlier 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?

That was the pedantry that they were trying to preempt.

Re: Python 3.15: features that didn't make the headlines

#180
post #15

I 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.

It’s completely the opposite. LLMs write awful python. Horrendous. They write pretty reasonable go and do it quite quickly.

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.

Post reply on HN