News for hackers. Stuff that matters.
Re:Smart Performance Hacks for Faster Python Code by woodruffw on Thursday November 20, 2025 @12:17PM (#45995027)
Python's strong native story has always been one of its biggest draws: people find it ironic that so much of the Python ecosystem is native code, but it plays to Python's strength (native code where performance matters, Python for developer joy/ergonomics/velocity).

> Even if you call into fast code from Python you still have to contend with the GIL which I find very limiting for anything resembling performance.

It depends. A lot of native extension code can run without the GIL; the normal trick is to "detach" from the GIL for critical sections and only reconnect to it once Python needs to see your work. PyO3 has a nice collection of APIs for holding/releasing the GIL and for detaching from it entirely[1].

[1]: https://docs.rs/pyo3/0.27.1/pyo3/marker/struct.Python.html#m...

Re:Smart Performance Hacks for Faster Python Code by lunias on Thursday November 20, 2025 @12:55PM (#45995491)
I didn't know about detaching from the GIL... I'll look into that.

> native code where performance matters, Python for developer joy/ergonomics/velocity

Makes sense, but I guess I just feel like you can eat your cake and have it too by using another language. Maybe in the past there was a serious argument to be made about the productivity benefits of Python, but I feel like that is becoming less and less the case. People may slow down (a lot) writing Rust for the first time, but I think that writing JavaScript or Groovy or something should be just as simple, but more performant, do multi-threading out of the box, and generally not require you to use other languages to implement performance critical sections as much. The primary advantage that Python has in my eyes is: there are a lot of libraries. The reason why there are a lot of libraries written in Python? I think it's because Python is the number 1 language taught to people that aren't specifically pursuing computer science / engineering or something in a closely related field.

Re:Smart Performance Hacks for Faster Python Code by woodruffw on Thursday November 20, 2025 @01:09PM (#45995672)
Yes, I think Python is excellent evidence that developer ecosystems (libraries, etc.) are paramount. Developer ergonomics are important, but I think one of the most interesting lessons from the last decade is that popular languages/ecosystems will converge onto desirable ergonomics.
Re:Smart Performance Hacks for Faster Python Code by SAI_Peregrinus on Thursday November 20, 2025 @12:34PM (#45995242)
Python is the ultimate (for now) glue language. I'd much rather write a Python script to glue together a CLI utility & a C library with a remote database than try to do that all in C or Rust or BASH.
Re:Smart Performance Hacks for Faster Python Code by lunias on Thursday November 20, 2025 @01:04PM (#45995602)
Yeah, it's great for stuff like that, but I find myself using Node more in that area.