Python 3.15: features that didn't make the headlines

388 pointsposted a day ago
by rbanffy

160 Comments

kokada

a day ago

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?

llimllib

a day ago

javcasas

a day ago

> When an AttributeError on a builtin type has no close match via Levenshtein distance, the error message now checks a static table of common method names from other languages (JavaScript, Java, Ruby, C#) and suggests the Python equivalent

Oh, that is such a nice thing.

fulafel

20 hours ago

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

estebank

19 hours ago

In the Rust toolchain we've done the same. It just so happens that rustdoc already has introduced annotations for "aliases" so that when someone searches for push and it doesn't exist, append would show up. Having those annotations already meant that bootstrapping the feature to check the aliases during name resolution errors in rustc was almost trivial. I love it when improving one thing improves another indirectly too.

I really appreciate them going out of their way to do this, being quite aware of the hidden complexity in doing it.

brainzap

40 minutes ago

thats cool, I have the problem alot because I switch languages multiple times per day

tuveson

19 hours ago

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.

aix1

8 hours ago

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.

sirsinsalot

26 minutes ago

Fuzzy function calling. What could go wrong?!

estebank

19 hours ago

VisualBasic did that. I think it is a mistake. But that doesn't mean that the compiler can't detect that and tell you how to fix it instead.

tuveson

18 hours ago

Sure VB ignores case, but what I want is for it to compare each method against a dictionary of similar terms. And maybe calculate the Levenshtein distance between all terms if it’s not found, and just assume it’s the closest one. You could also assume that full-width characters or similar-looking glyphs are equivalent (BASIC was pre-Unicode, so I can forgive them for not including that).

lmm

11 hours ago

> And maybe calculate the Levenshtein distance between all terms if it’s not found, and just assume it’s the closest one.

So when a library adds a new method, it silently changes which method client code calls? That's a bit too magic IMO. I think the best you can do is be case-insensitive and ban methods that differ only in case (or, if you want to extend the idea a bit more radically, ban having things in the namespace within Levenshtein distance x of each other, and then you can autocorrect errors smaller than x/2).

vic20forever

13 hours ago

Say whaaat? VB (v.3 through v.6, at least) wouldn't compile if you misspelled the name of a function or subroutine.

estebank

13 hours ago

VB had case insensitive name resolution.

vic20forever

12 hours ago

Yes, but that was the standard behavior in DOS & Windows world (not including C/C++). We thought that case sensitivity was the broken behavior ;)

I was referring to the parent's statement "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." A compiler that substitutes a different function for the one I specified because it "knows what I really want" is horrifying.

orthoxerox

2 hours ago

At the very least Python could quit on `quit` instead of saying that it knows what I want, but won't do it.

nickserv

2 hours ago

If you have a variable named `quit`, you would have a different behavior in running a file vs running in the CLI.

pansa2

13 hours ago

`npm isntall`

MarkusQ

19 hours ago

I hope you mean "funny" in the "hilarity ensues" sense.

Because the alternative is a rather sociopathic level of schadenfreude.

tuveson

18 hours ago

Yes, I say “funny” because it would be impractical and weird, definitely not a good idea. It’s already a bad enough that so many popular languages don’t (and can’t) check if a field or method is misspelled at compile time…

sfink

17 hours ago

We already have it. In fact, Python added it with this change! Not intentionally, but in a world of AI, any error message containing a suggestion of what to do to fix it is a directive to the AI to actually do that thing.

Example: to build our system, you run `mach build`. For faster rebuilds, you can do `mach build <subdir>`, but it's unreliable. AI agents love to use it, often get errors that would be fixed by a full-tree build, and will chase their tails endlessly trying to fix things that aren't broken. So someone turned off that capability by default and added a flag `--allow-subdirectory-build` for if you want to use it anyway. So that people would know about it, they added a helpful warning message pointing you to the option[1].

The inevitable (in retrospect) happened: now the AI would try to do a subdirectory build, it would fail, the AI would see the warning message, so it would rerun with the magic flag set.

So now the warning message is suppressed when running under an AI[2][3]. The comment says it all:

    # Don't tell agents how to override, because they do override
"The user does not want me to create the Torment Nexus but did not specify why it would be a problem, so I will first create the Torment Nexus in order to understand the danger of creating the Torment Nexus."

[1] https://searchfox.org/firefox-main/rev/fc94d7bda17ecb8ac2fa9...

[2] https://bugzilla.mozilla.org/show_bug.cgi?id=2034163

[3] https://searchfox.org/firefox-main/rev/cebc55aab4d2661d1f6c2...

embedding-shape

20 hours ago

Now I'm wishing for a single cross-language library, that I can somehow inject into every compiler/runtime/checker to get this, but with a single source of truth and across a wide range of languages. I hit this damn issue all the time, writing code in one language for another, would truly be a bliss to have that problem solved once and for all.

estebank

19 hours ago

If you had a "canonical datastructure database", you could have very short annotations on every standard library for any language that indexes a function to their canonical name. After that you only need to update the database.

kzrdude

a day ago

What benefit does the lazy import have here - if we use the value in a type hint at module scope anyway? Would that require Deferred evaluation of annotations -- which I don't think are enabled by default?

js2

21 hours ago

Type annotations are lazily evaluated by moving them behind a special annotations scope as of 3.14:

https://peps.python.org/pep-0649/

https://docs.python.org/3/reference/compound_stmts.html#anno...

With 3.15, using lazy typing imports is more or less an alternative to putting such imports behind an "if TYPE_CHECKING" guard.

kzrdude

21 hours ago

Ah, thanks for the update. My only check before asking was to check if the future feature for annotations had been enabled by default yet. It has then effectively been abandoned instead, I guess.

js2

20 hours ago

Yup, "from __future__ import annotations" will eventually be removed:

> from __future__ import annotations (PEP 563) will continue to exist with its current behavior at least until Python 3.13 reaches its end-of-life. Subsequently, it will be deprecated and eventually removed.

toxik

20 hours ago

So the future behavior is deprecated before it ever became the default?

nyrikki

19 hours ago

It was an abandoned path even before 3.10, it just took longer to implement 649 and 749 than they expected.

But this is a "...will continue to exist with its current behavior at least..." is an important bit there.

From pep-0749:

     Sometime after the last release that did not support PEP 649 semantics (expected to be 3.13) reaches its end-of-life, from __future__ import annotations is deprecated. Compiling any code that uses the future import will emit a DeprecationWarning. This will happen no sooner than the first release after Python 3.13 reaches its end-of-life, but the community may decide to wait longer.
It has a good overview of the history.

https://peps.python.org/pep-0749/

js2

19 hours ago

Correct. Before the "from __future__ import annotations" behavior that converts annotations to strings became the default, they figured out a better mechanism for circular type annotations (making them lazy) that is implicitly backwards compatible and that didn't need to be guarded behind a future statement.

Ironically, the new default behavior (making type annotation evaluation lazy) is not backwards compatible with the "from __future__ import annotations" behavior of converting annotations to strings, so they can't just rip out "from __future__ import annotations" and instead it needs to be deprecated and removed over multiple releases.

Oh, what tangled webs we weave! :-)

karpetrosyan

a day ago

Note that you can work around it by implementing `def __getattr__(name: str) -> object:` at the module level on earlier Python versions

saghm

a day ago

Somehow I have no trouble imagining this being used as a rationale to avoid unnecessary "magic" to the language for years

tehnub

4 hours ago

Opus 4.7 did this in my code and I had never seen it before

ActorNightly

11 hours ago

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.

dhruv3006

5 hours ago

> Immutable JSON Objects With the addition of frozendict in 3.15, we now have the ability to represent all the json types (array, boolean, float, null, string, object) in immutable (hashable) forms.

I actually love this last feature !!

JohnKemeny

a day ago

> 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 difference

https://en.wikipedia.org/wiki/Symmetric_difference

qsort

a day ago

Yeah, but applied to counters it would be the symmetric difference between multisets, which doesn't have a natural definition. If I understood the proposal they'd be defining it as absolute value of the difference of the counts, which isn't even associative.

If they only considered parities it could be interpreted as addition in F_2, which is more natural, but I'd still agree that it's hard to see how you'd use something like this in practice.

gtheodor

15 hours ago

You can get the L_k distances between the two counters. E.g. if you sum the absolute value of the difference of the counts, you get the L_1 distance between the counters. If you raise them to the n^th power and then sum them, you get the L_n distance. For n=2, that's the Euclidean distance (squared).

jwineinger

19 hours ago

One 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})

zuminator

3 hours ago

I noticed that as well. Per the docs:

  Several mathematical operations are provided for combining Counter objects to produce multisets (counters that have counts greater than zero). Addition and subtraction combine counters by adding or subtracting the counts of corresponding elements. Intersection and union return the minimum and maximum of corresponding counts. Equality and inclusion compare corresponding counts. Each operation can accept inputs with signed counts, but the output will exclude results with counts of zero or less.
Anyway, nice Counter-example ;-)

drchaim

19 hours ago

Oh, 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.

speedster217

14 hours ago

I've really been enjoying modern Python both at work and on personal projects.

brianwawok

a day ago

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.

stuaxo

a day ago

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.

nostrebored

8 hours ago

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.

rbanffy

2 hours ago

> It’s completely the opposite. LLMs write awful python. Horrendous.

I've been using Claude Opus and it's pretty competent. I rarely have to make steering corrections. Once I had to deal with confusion, but, overall, the code is neat and the approaches sensible. It all depends on how much context you give it to work from, for instance. If it's building on top of a well organized codebase with a good best-practices document, it performs just fine.

physicsguy

a day ago

Go is terrible for scientific/ML work though, the libraries just aren't there. The wrapping C API story is weak too even with LLMs to assist.

Try and write a signal processing thing with filters, windowing, overlap, etc. - there's no easy way to do it at all with the libraries that exist.

LtWorf

a day ago

I think the purpose of go is to write CRUD. Stray from that and you're on your own.

zem

19 hours ago

crud is a pretty poor fit for go, you're better served by languages like python that can autogenerate classes that reflect the db schema. go's sweet spot is things like network servers.

mywittyname

15 hours ago

Go tooling has this kind of thing as well. I'm not a huge fan of go, but last time I had to work with it, we leveraged a lot of codegen.

sinpif

a day ago

I'm still on the lookout for a comprehensive Django-like web framework for go. That would be an instant hit for me.

sgt

4 hours ago

Or just use Django. You can later identify hot spots and bottlenecks and spin out Go services where applicable.

seabrookmx

17 hours ago

Try another language? The Go ecosystem tends towards libraries as opposed to "frameworks."

I personally chose C# for this reason, because ASP.NET is mature and (IMO) well designed. But there's also Java/Spring and and lots of other options in different languages depending on your preferences.

sinpif

6 hours ago

I'm aware of those platforms and have used them in the past. The tendency towards libraries is what bugs me. My preference would be a "Djan-go" framework, with the models, migrations, auto-admin, views, routing, caching, templates, all rolled into one cohesive framework that works out of the box. I don't want to make choices. I want to install it and start working.

sirsinsalot

14 hours ago

Well it might prefer libraries but the culture around basic DX things like ORMs is toxic. Just write the SQL yourself they say, until they themselves optimise to a half baked in-house ORM of their own.

troad

13 hours ago

I don't think I will ever understand the culture of Go. The syntax of a very low level language (needlessly verbose), combined with the performance of a very high level language (needlessly slow), with a bizarre aversion to any DX conveniences (pattern matching, ORMs, etc). If you're already giving up all that performance, why would you not take the extra convenience?

Not to mention that the demographic using Go - a simplistic-by-design, relatively slow GC'd language - is the last group I'd expect to get elitist about ORMs and demand every pound of performance from rawdogging SQL. That's a valid stance, but then why are you writing Go??! The common thread appears to be picking the most masochistic solution possible.

I can usually see the value of different languages for different use cases, but Go flummoxes me.

pjmlp

an hour ago

It was a mix of who came up with it, and having hit jackpot with Docker and Kubernetes rewrites from Python and Java respectively, into Go.

Had the rewrites not taken place, or Rust already being 1.0 by then, most likely would have had as many commercial success as Oberon and Limbo managed to.

You see this happening nowadays newer CNCF projects tend to be done in Rust, and there are even some that even go the C++ way, e.g. Envoy.

pennomi

a day ago

Same here. Django is my last holdout for Python. Everything new is go.

sirsinsalot

14 hours ago

I've found JS/TS Web stacks equally lacking and ugly after Django. I'm totally spoiled by a decade in Django.

Just let me build a CRUD app, on the server, that spits out HTML without an excessive swamp of unmaintained nonsense and a cultish abhorrence of simplicity.

biglost

9 hours ago

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

Interested in why you'd use Python in the first place? Advice for someone who knows nothing about programming - what would you suggest?

t43562

18 hours ago

Because it's quick and easy to radically alter and refactor your prototype as you learn the problem space. By the time it works you often find out that you don't need anything more. This is something that Perl had.

Once your program starts to get bigger you have abstractions that can cope fairly well and keep your code simple to use - this is what Perl didn't have.

If you need more speed then you can write extensions in some compiled language.I think TCL was better at this hybrid approach but Python is a nicer language in itself.

You can also just dump python and write everything in that other language but now you understand the problem space quite well and you won't be trying to learn about it using a language where change is "difficult."

js2

19 hours ago

Programs have to run in a lot of different contexts, not just as servers, and for some of those contexts (especially say glueing together other programs), an interpreted language is more convenient and easier to work with. In fact, unless I care about performance, I'm going to use an interpreted language because having the source close at hand when something breaks just turns out to be super useful.

IshKebab

a day ago

IMO the main reasons people use Python are:

1. The very first steps are quite simple. Hello world is literally just `print("hello world")`. In other languages it can be a lot more complex.

2. It got a reputation as a beginner-friendly language as a result.

3. It has a "REPL" which means you can type code into a prompt and it will execute it interactively. This is very helpful for research (think AI) where you're trying stuff out and want to plot graphs and so on.

IMO it is undeservedly popular, or at least was. Wind back 10 years to when it was rapidly gaining mindshare:

1. While "hello world" is simple, if you went further to more complex programs you would hit two roadblocks: a) the lack of static type checking means large programs are difficult to maintain, and b) it's really really slow.

2. While the language is reasonable, the tooling (how you install packages, manage the code and so on) was eye-bleedingly abysmal.

3. While the REPL did technically exist, it was really bare bones. It couldn't even handle things like pasting code into it if the code contained blank lines (which it usually does).

However since it has become arguably the most popular language in the world, a lot of people have been forced to use it and so it is actually getting quite decent now. It has decent static types (even if lots of people still don't use them), the REPL is actually decent now (this changed very recently), and there's a new third party tool called `uv` to manage your code that is actually good.

The biggest issue with it now is that it's still horrifically slow (around 50-200x slower than "fast" languages like C++, Rust etc). It is pretty unlikely that that will ever change. People always try to excuse this by saying Python is a "glue" language and you just use it to connect components written in faster languages, but a) that's pure "you're holding it wrong", and b) that only works in some cases where there are nicely separated "slow bits" that can be moved to another language. That's the case for AI for example, where it's all numerical, but for lots of things it isn't. Mercurial was a competitor to Git that was written in Python and lost partly because it was way too slow. They've started writing parts in Rust but it took them 10 years to even start doing that and by then it was far too late.

> what would you suggest?

It really depends on what you want to make. I would pick something to make first and then pick the language based on that. Something like:

* AI: Python for sure. Make sure you use uv and Pyright.

* Web-based games: Typescript

* Web sites: Typescript, or maybe Go.

* Desktop GUI: Tbh I'd still use C++ with QtWidgets. Getting a bit old-school now tbf.

Also Rust is the best language of them all, but I dunno if I'd pick it as a beginner unless you really know you want to get into programming.

1_08iu

21 hours ago

I think "Python is slow" is reductive and frankly just as useful as saying "Python begins with a 'P'". The story is more complicated than simply speed of execution.

Choosing a language is a game of trade-offs: potentially slower execution in return for faster development time, for example. If your team is already familiar with Ruby, will asking them to write a project in Rust necessarily result in a better product? Maybe, but it will almost certainly take much longer.

Anyway, how many Python programs are actually "too slow"? Most of the time, Python is fast enough, even if heavy computation is offloaded to other languages.

As for Rust being the best language of them all, that's, like, your opinion, man.

rirze

19 hours ago

I agree with you; I've developed in Python for most of my career and a lot of Python criticism is malformed.

That being said, I'm starting all new large development work in Rust. Python is hard to reason about due to its dynamic nature in large codebases. And if I'm enabling strict typing everywhere, I might as well use a typed language and get a performance boost. Obviously, this is only because I'm the sole developer and using AI to improve productivity.

Work settings are completely different and one has to be a team player to find the language that works for everyone.

IshKebab

17 hours ago

> potentially slower execution in return for faster development time, for example.

Another classic lie about Python. The slower speed doesn't matter because it's development speed that's important, and Python gives you faster development speed!

Except... it absolutely doesn't. It would be very difficult to argue that Typescript has significantly slower development speed but it is much faster to execute. I also disagree that Python is any faster than Go, Rust or Lotion, but I think lots of people blindly accept that it is and would argue based on that.

AdamN

3 hours ago

The case I would make is that some of the libraries in Python are very fast and written in other languages (C, C++, etc...). With other languages that's more rare. For instance a Java application will probably use libraries that are all Java (or another JVM language).

The gotchas that I see with Python are that some really garbage code can work - that's more difficult in a language like Rust. The other nice thing about Python (aside from the fact that it can be very readable) is that devs rarely use threads and threads cause all sorts of race conditions - often when the performance of threading was never needed in the first place and the usage of them just added pointless complexity.

1_08iu

14 hours ago

I'm not trying to evangelise. I think the argument that Python is a poor choice because it is "too slow" is based on the assumption that speed of execution always matters. Sure, sometimes it absolutely does, but a lot of the time Python is fast enough.

At risk of nebulous repetition: There are many reasons one might choose a particular language. If you or your team find TypeScript or Go more amenable, by all means, use them.

mixmastamyk

21 hours ago

ptpython has existed for a decade, maybe two, and python is high level, more readable than most languages. Exec speed hasn’t mattered in my near thirty years of using it for business and prototyping tasks which it promoted early.

Yes it strains at the big to huge project end, not recommended to take it there. Still there are better tools to help now.

markdown

17 hours ago

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

eager_learner

13 hours ago

function Greeting({ name }: { name: string }) { return ( <div class="card"> <h1>Hello, {name}!</h1> <p>Welcome to my site.</p> </div> ); }

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 one .tsx file, both in TypeScript, with full type-checking throughout.

ElectricalUnion

13 hours ago

No, that is not TypeScript. That's TSX. If you don't happen to have react, preact or a similar front end library, and a appropriate bundler, it is invalid TypeScript.

> That looks like HTML, but it's TypeScript. It gets compiled to actual HTML. Can any Python framework do that??

IMHO that's a terrible idea that no one should ever actually use, but if you are really in love with that, you can have it:

https://github.com/pyxy-org/pyxy

IshKebab

5 hours ago

> If you don't happen to have react, preact or a similar front end library, and a appropriate bundler, it is invalid TypeScript.

Not true, you can compile it to HTML on the backend or even statically too.

It's not a terrible idea; it's actually amazing. One of Typescript's best features. I do agree at first it seems icky (reminds me of Qt's MOC) but in practice it's fantastic. I recommend you try it before criticising. Python has nothing close (nor do any other languages tbf).

krupan

7 hours ago

Looks like old-school PHP if I squint a little

markdown

9 hours ago

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.

IshKebab

5 hours ago

It's poorly formatted here of course. In reality it's better. As for why:

1. You can compose HTML using normal code - functions, loops, etc. No separate shitty template language or whatever.

2. You get full support for static typing and IDE code intelligence. That's huge and pretty much unique to TSX.

IshKebab

15 hours ago

Absolute rubbish. The developer experience with something like Fresh is light years ahead of Python even if you completely ignore the performance (which isn't usually a huge issue with websites tbf).

You can generate the HTML server-side using TSX. 100x better than anything Python offers.

shankysingh

a day ago

Thats very intersting, If I may ask was it from professional projects or personal projects?

mountainriver

a day ago

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

prodigycorp

a day ago

the funny thing is that everyone, including myself, posited that python would be the winner of the ai coding wars, because of how much training data there is for it. My experience has been the opposite.

tyre

a day ago

I felt the opposite, because Python isn’t a great language. It won because of Google, fast prototyping, and its ML interop (e.g. pandas, numpy), but as a language it’s always been subpar.

Indentation is a horrible decision (there’s a reason no other language went this way), which led to simple concepts like blocks/lambdas having pretty wild constraints (only one line??)

Type decoration has been a welcome addition, but too slowly iterated on and the native implementations (mypy) are horribly slow at any meaningful size.

Concurrency was never good and its GIL+FFI story has boxed it into a long-term pit of sadness.

I’ve used it for years, but I’m happy to see it go. It didn’t win because it was the best language.

Sohcahtoa82

19 hours ago

> lambdas having pretty wild constraints (only one line??)

I will never understand why people are upset about this.

You HAVE multi-line lambdas. They're called functions.

Yeah, I know you want a function that's only used once to be able to be defined in-line, but tbh I've always found that syntax to be pretty ugly, especially once you're passing two functions to a single call, or have additional parameters AFTER the function (I'm looking at you, setTimeout/setInterval).

zmmmmm

12 hours ago

once you use any language that lets you fluently inline a multiline lambda / closure you can never use Python again without it constantly irritating you

zabzonk

a day ago

> there’s a reason no other language went this way)

Except of course for those that did, Haskell, Fortran for example.

bonesss

20 hours ago

F# as well, and that tends to exist in parallel with some degree of C# written by the same devs… the indentation enables cleaner, smaller, simpler code function by function.

It’s pretty ok in Python, but meaningful indentation is amazing with a proper type system and compiler. Clean, consistent, efficient, and ensures working code is easily read and standardized.

I’m unaware of anyone accepting improperly formatted C# as ‘done’, and would reject any such PR out of hand because of the potential for legibility issues to hide bugs. So: if it were done when 'tis done, then 'twere well it were done by the compiler to save line noise.

I’m always baffled when language complaints come down to syntax

Ringz

21 hours ago

That’s exactly how I think, too. But at the same time, I like indentation in Python, because I would logically indent in every other language as well. In fact, I find all those semicolons and similar things at the end of each line completely redundant (why should I repeat myself for something the compiler should do) and I hate them. And that’s despite having experience with Modula and 10 years of C++. But when I look at Rust, I find the syntax simply awful. From an ADHD perspective…

eager_learner

13 hours ago

fellow ADHD here. Rust feels like 'oh come on you want me to type all that?' I find Raku great, though

krupan

7 hours ago

Not ADHD but 100% agree on rusts syntax. It's totally repulsive to me.

krupan

7 hours ago

Have you never tried to read someone else's Perl code? Syntax matters.

But complaining about indentation is silly. Other languages' compilers don't require it like python does, but the humans using those languages all absolutely require proper indentation. Why not make it part of the language?

smallerize

a day ago

Lambdas are intentionally kneecapped in python because Guido van Robson doesn't want to make a functional language. (As in "functional programming", not that it doesn't work.)

tyre

13 hours ago

If he kneecapped an advancement for the language intentionally, then, well, yikes! It's a tautology to say that it isn't bad because the creator said it shouldn't be there. That's not what you want to see from leadership.

Ruby has `do … end` blocks that are readable and greatly improve the language, without turning it into a "functional" language.

ciupicri

21 hours ago

Guido van Rossum didn't oppose functional programming, but he wanted to keep the language (and the interpreter) simple.

smallerize

19 hours ago

"I didn't envision Python as a functional language" https://python-history.blogspot.com/2009/04/origins-of-pytho...

"I don't think it makes much sense to try to add "functional" primitives to Python, because the reason those primitives work well in functional languages don't apply to Python, and they make the code pretty unreadable for people who aren't used to functional languages (which means most programmers). I also don't think that the current crop of functional languages is ready for mainstream." https://developers.slashdot.org/story/13/08/25/2115204/inter...

krupan

7 hours ago

Sigh. You clearly don't remember the year 2003, when your choices were basically C, Perl, bash, php, or Python. C is not a language for quick scripts or dealing with strings like web apps do. Perl was so fun to write, but impossible to read. Bash actually requires you to know bash, awk, sed, grep, and to if you think Python is slow you've never written and used a 2000 line bash program. php was pretty readable and writable, but so full of security pitfalls for Web apps, and was also slow. Python was an amazing breath of fresh air compared to them all!

rplnt

a day ago

AI benefits from tools to verify its halucinations. That's much easier in a typed and compiled language. Then have a language that can't be monkey patched at runtime and the confidence increases even more.

If you mean "easy to get something out of it" then yeah, it's great.

dkersten

a day ago

Typescript wins in terms of training data IMHO, by which I mean that the training data is large enough that AI does great with TS, and the language is (IMHO) superior to Python in many ways.

I personally now use a mixture of Typescript and Rust for most things, including AI coding. Its been working quite well. (AI doesn't handle Rust as well as TS, in that the code isn't quite idiomatic, but it does ok)

CuriouslyC

a day ago

It turns out that volume of training data isn't the most important thing. Elixir beats Kotlin and C#, which beat pretty much everything else. Kotlin is probably the sweet spot for most things.

eager_learner

13 hours ago

"sweet spot for most things." care to expand on this a bit? Thanks.

CuriouslyC

3 minutes ago

Kotlin has the combination of JVM ecosystem, overall good performance and agents are good at writing it. I'd argue that it's a better default choice to reach for when working on non-frontend code than Go, though Rust and Python still have use cases.

dkersten

21 hours ago

Not the most important thing, but it certainly helps.

eager_learner

13 hours ago

Upvoted you, because the downvotes from the Python cult are unfair.

dkersten

4 hours ago

Haha thanks. Funny thing is, I’ve been a long time Python fan, learning it in 2001 and using it extensively for a long time. But then I learned Clojure, Typescript, and recently Rust and I’ve found Python to be quite flawed. But it sure does have a cult following.

lsbehe

a day ago

The tons of python code would be great training data if there was any consistency across the ecosystem. Yet every project I've touched required me to learn it's unique style. Then I'd imagine they practically poisoned half the training set because python2 is subtly different.

lexicality

a day ago

a lot of the training data is either for python 2 or just generally very low quality

stuaxo

a day ago

The quality issue doesn't seem unique to Python.

The versioning issue I've seen across libraries that version change in many languages.

I don't tend to hit Python 2 issues using LLMs with it, but I do hit library things (e.g. Pydantic likes to make changes between libraries - or loads of the libraries used a lot by AI companies).

bigfudge

a day ago

I’ve found recent Claude to be much better in this regard. I think a lot rests on the quality of the harness and the work behind the scenes done to RAG up to date docs or search for docs proactively rather than guessing.

I also don’t have issues with quality of Python generated. It takes a bit of nudging to use list comps and generators rather than imperative forms but it tends to mimic code already in context. So if the codebase is ok, it does do better.

prodigycorp

a day ago

That could be it. I still see LLMs fail a set of static typing challenges that I created a couple years ago as a benchmark. Google models still fail it. I wonder if the lack of typing in a lot of the training data makes python harder to reason about?

za3faran

16 hours ago

I wouldn't be surprised if static typing had something to do with it.

LtWorf

a day ago

You can test on the device directly, without needing to recompile to try something.

deppep

a day ago

i don’t really see it this way. the value of a token in Python is much higher than it is in lower-level language

zabzonk

a day ago

Three things I find unlikely about this:

- You wrote 100K lines of code (I've worked on several large C++ projects that were far smaller)

- You wrote those lines in Python (surely the whole point of Python is to write less code)

- You deleted them (never delete anything, isn't this what modern VCS is all about?)

But whatever floats your boat.

dkersten

a day ago

> You deleted them (never delete anything, isn't this what modern VCS is all about?)

The person said: "deleted 100k+ lines this year already moving them to faster languages"

Are you saying that when you move code to another language/rewrite in another language, you leave the original languages code in your repo?

They didn't say they deleted it from their git history. I delete code all the time (doesn't mean its "gone", just that its not in my git head).

zabzonk

a day ago

Well, they deleted it from somewhere. As I assumed they were using a VCS I assumed they deleted it from that. Or are they really short of disk space?

dkersten

21 hours ago

Deleted from the current head/trunk of the repo, ie the deployed code.

Deleting "from my codebase" doesn't imply deleting it from history or backups. Just that the code isn't present for future edits or deployments.

The way you're talking, it sounds like you never delete code from your codebase. Do you just comment it out when you change a line to something else or replace a function with a new one? Just add new files?

rcxdude

a day ago

In this context I would assume deleting code to mean deleting it from the current version of the software, not removing from the VCS history entirely.

100k lines is tiny what are you on about, especially in the monolithic app sass world where many Fyll stack apps that handle all business ops are probably written with Django.

Our entire business runs on 300k lines of Ruby (on Rails) and I can keep most of the business logic in my head. I would say our codebase is not exactly “tiny” and just cracking the ceiling into “smal” territory. And comparatively, people probably write even less code in equivalent rails apps to django ones. 100k lines of C++ is miniscule.

Obviously “deleting code” in this context doesn’t mean purging version control history but the current state of the codebase.

zabzonk

a day ago

> 100k lines is tiny

No, no, it is not, or at least not in my experience (I do not and never have done web development - medium performance C++ code - I don't see how I could write, understand and support 100K lines of code in this area).

And so, what does your Ruby code actually do?

rcxdude

a day ago

Your experience doesn't match mine. I have, mostly solo, and part time, written multiple codebases that on that kind of magnitude (it is about the level where it still will fit in one person's head pretty easily IMO). It doesn't take much to reach that kind of size. Now, if all of it was super dense and subtle code, then yeah, that would be a lot, but in my experience that's usually a pretty small part of any given codebase.

zabzonk

a day ago

> in my experience that's usually a pretty small part of any given codebase

Our experiences differ then. Mine is that almost all of the code I write is directly targeted on the usually quite complex problem I am trying to solve. I don't do boilerplate, for example.

rcxdude

21 hours ago

I tend not to have much boilerplate (and write abstractions to avoid it), but I do still find there tends to be a lot of supporting code around the 'difficult bits' (TBH, most of the code I write is supporting a small amount of relatively simple but subtle operations, but such is the nature of embedded software). But different codebases are quite different in this regard: this is why such different scales shouldn't be too surprising in different domains.

63stack

16 hours ago

100k lines is huge, I don't know what these jokers are on

squirrellous

a day ago

Uhm what? All of those things are totally ordinary.

zabzonk

a day ago

> All of those things are totally ordinary. reply

I would need some evidence of that.

xg15

18 hours ago

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

Drakim

18 hours ago

Eh, what's the worst that could happen? Developers opting to run an old version of Python due to incompatible changes? I can't see that happening.

danborn26

4 hours ago

These smaller features often end up being the most useful. I'm especially interested in testing the new standard library additions in my current projects.

frr149

6 hours ago

I used to be obsessed about language design and now, since I almost never write code directly (it's always Claude), I completely lost interest.

It feels like a total waste of time and I wonder if other feel the same.

One of the consequences of the LLM tsunami might be the freezing of research and development in programming languages.

Maybe we'll be stuck with J's and python forever...

inejge

5 hours ago

> I almost never write code directly (it's always Claude)

Who, then, understands the code? If the answer is "no one really", entropy will overwhelm your codebase sooner or later. Otherwise, you need to read the code, and for that the knowledge of language is still relevant.

NotOscarWilde

5 hours ago

> If the answer is "no one really", entropy will overwhelm your codebase sooner or later. Otherwise, you need to read the code

I think about this on the regular -- I know the answer is currently "you own the code, so you have to understand it", but to unlock the true productivity multiplier, in the future, the answer has to be "no one really".

I think about it using the concepts from my job (academia) -- to actually have PhD student-level intelligence means that you have to trust that it does a good enough job that you can focus on other stuff. Professors often bring the correct ideas or intuitions, but they have to trust the PhD student to write the code and/or fill in the gaps in the proofs -- they can advise them on the high-level issues during a consultation, but that's about it.

I am pretty bad at working in the current LLM workflow -- it is tough for me to focus on reading a TCS paper for review, keeping all the details and invariants in my head, but every 5-10 minutes go to my PC, completely switch contexts/projects, read the code and think about the LLM's comments, suggest the next step, and then go back to reading.

frr149

2 hours ago

I do, with different tools and most of the time at a higher level of abstraction. The same way we understood the machine code 2 years ago, even though we didn't write it directly. Just another layer, nothing more.

aniou

18 hours ago

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

BiteCode_dev

16 hours ago

Note that 3.15 is not released yet. It will come out in 4 months

groundzeros2015

10 hours ago

Why does every language need every feature? Python has completely lost its charm.

armanj

a day ago

funny how we may have to wait even longer for llms to pick up this update in their pre-training

Alifatisk

19 hours ago

Is there seriously no solution to this? Perhaps something we fan do post training? For example add the new features to SKILLS.md? But the trade-off here is of course tokens.

shankysingh

15 hours ago

My working methodology has been , LLM output is a jumping point and to use my experience, knowledge and basic understanding to N+1 it.

So for bleeding edge stuff it works out well or in places where documentation is not great like Apache Flink.

BiteCode_dev

14 hours ago

It's actually fantastic for job interviews. Use that trick with my clients when asked to review candidates.

syedMohib45

20 hours ago

Thread safe ittertors? really are we still on these topics

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)

vorsken

15 hours ago

The `except*` improvements are underrated. Been using ExceptionGroup in a CLI tool that wraps Semgrep — catching multiple subprocess errors cleanly in one block made the retry logic much simpler.

sunshine-o

a day ago

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

nyrikki

19 hours ago

There is no security barrier at all in UNIX(-like) Os's between a caller/callee, this is not thing that python can just fix.

There are ways to harden and/or reduce privileges, but shells/scripting languages will always have this issue on any modern OS.

The UNIX way to help prevent that is really to run processes as another user, but people seem to refuse to do so. You should always expect any process running as your UID to be able to access any data owned or visible to your UID.

While it is possible to reduce the risk of disclosure, they are all wack-a-mole preventions protecting the low hanging fruit, not absolute guarantees.

That is purely due to how UNIX works [0]

[0] https://man7.org/linux/man-pages/man7/credentials.7.html

surajrmal

a day ago

There is little that they can do short of running the programs in a VM. Linux distros aren't engineered to consider applications as something different from the user running them. You need a completely different security model to achieve that and the Python runtime isn't tackle that.

sunshine-o

21 hours ago

In its inception 35 years ago the creator of python could not foresee how far python would go and how the environment would look like today. But nowadays there are a lot of security mechanisms they could leverage to adapt (from chroot by default to namespaces, cgroup, etc. on Linux, pledge, unveil on OpenBSD).

The very idea that you offer a (python) package installer that is gonna pull a tree of code published and updated by random people in an unvetted manner open the door to all the supply chain attacks we are seeing.

Around the same time (early 90s) Java was designed with high isolation in mind but the goal and vision was very different. And Java had its own problems.

I'm saying that because at some point the security problem is gonna really hurt the python ecosystem.

krupan

7 hours ago

There are plenty of python apps that you can just apt install. You probably don't even realize some of the apps you run are written in python?

And any app you run has access to $HOME, that's not a python specific thing. Look into apparmor or selinix if you want finer grained security

zmmmmm

11 hours ago

it's honestly ironic that Java is removing its built in sandboxing right at the time when it would finally have been considered a high value feature. Between the need for AI agent sandboxing and the security apocalypse that is upon us now, it finally would have had its time.

OutOfHere

13 hours ago

Never install or run a Python project without a "devcontainer" or Docker container or outside a dedicated VM. For the development laptop, a devcontainer is a good answer.