3 ms·
As someone who uses python a lot, I don't see the point. I guess as a language writer you like to improve things, but as a user I'm good. If you want speed, yo
by lordnacho 6y ago
As someone who uses python a lot, I don't see the point. I guess as a language writer you like to improve things, but as a user I'm good.
If you want speed, you need complete control, mainly over memory. Custom allocator, that kind of thing. It's painful and annoying, but I do that in cpp because that's what people do and it's a skill that you can find in the market.
So when do I use python? When I really don't care at all about speed. Glue code, and that's a lot of code, is best in python. Moving files around, pulling data from some Web server, orchestration. Easy to understand, terse, simple to change, portable. This is also why coding quizzes are best done in python.
Also things that have few types but need to be fast, they make sense as a python wrapper. Classic is numerical stuff. Set up some matrices, turn a handle that drives a native lib.
That makes a kind of barbell. Fast to write and simple to understand, vs slower to write and more complex. This is probably why you see so many ads in the trading world for someone who does cpp and python.
Making python itself faster won't bring it to where it can be used instead of cpp, and it already is just a wrapper where the real work is done by cpp. The glue code we didn't care about in the first place because it's never a bottleneck.
- sgtnoodle 6y agoI dunno, I think it would be a big improvement that would be generally appreciated by a lot of people, even if it's an incremental optimization. There are lots of programs that are CPU bound but implemented in python for various good reasons. Doubling execution speed of those programs is like doubling single core CPU speed. I wrote a simulation of sorts in python a few months ago, and a scenario runner to crank through as many simulations in parallel as possible. I didn't have any particular goal for runtime, but the faster the better. I spent a day replacing an iterative solver with a closed form solution, and that made it about 10x faster alone. I spent another 20 minutes turning classes into slots and got an easy 50% boost on top of that. I run that code for a couple minutes every few days on my 8 core laptop from 2020. On my 5 year old laptop with half the cores, the same task is more like 5 minutes. Doubling the speed of that code would be really nifty, in that it would make the 5 year old laptop take a couple minutes, and the modern laptop take less than a minute. I'd probably double the number of scenarios and get a more statistically significant result for what I'm simulating. I also like to use Cura for 3D printer slicing. That's pretty much all written in python, and while it's gotten faster over time it's still pretty darn slow. If that doubled in speed, it would be an awesome upgrade.
- coldtea 6y ago>As someone who uses python a lot, I don't see the point. Yeah, who would appreciate a doubling of speed, e.g. needing half the servers or serving non-cached responses faster, or their scripts finishing in half the time, and so on... I mean, if there was tradeoff for the end-user sure, but as it is, I can't even understand the reasoning behind this comment. >If you want speed, you need complete control, mainly over memory. That I might be OK without the ultimate in speed (that I'd have with the above in C or Rust, etc.) does not mean I would not absolutely appreciate more speed in the things I use Python for now, especially if it came for "free" (e.g. not with Cython or having to wrap C extensions, etc.). Would you be saying the same ("doesn't matter") if Python was instead made 2 times slower?
- lordnacho 6y ago> Would you be saying the same ("doesn't matter") if Python was instead made 2 times slower? I mean I guess at some point (5x, 20x, 100x) it would be unbearable, but yes. It's nice for the tool to get better "for free" but if it's so far from becoming the right tool for certain tasks, what's the benefit? Also it might not be "for free", I don't know what Guido is planning, but if you look at when people try to make Java or c# fast, it changes how you use the language by a lot. So yeah it's nice for python to get faster but I won't know the difference at 2x or 0.5x, because I just don't use it for things where that matters. YMMV.
- coldtea 6y ago>It's nice for the tool to get better "for free" but if it's so far from becoming the right tool for certain tasks, what's the benefit? How about 30 seconds of my time saved everytime I run a 1 minute current script? Which I might do dozens of times every day? (Actually I run huge pipelines that include pure Python processing, and I would absolutely love a double-the-speed raw python).
- lordnacho 6y agoWell clearly it would have use for you, but my guess from experience is most people use it like me, it's a nice to read language that wraps something, or doesn't do much pure processing. My rule is if it's about the cutting edge of speed, it's cpp. If I'll never care about speed, it's python. If I care a little bit about speed, JVM.