3 ms·
Python, while slow, is "fast enough" because it's super easy to add native objects for anything that's too slow. It's kind of an inversion for the usual scripti
by taneq 5y ago
Python, while slow, is "fast enough" because it's super easy to add native objects for anything that's too slow. It's kind of an inversion for the usual scripting language layout with fast native code loading slow snippets of script to provide customization, and tbh that's probably the better approach for most situations. Write the 99% of your application that's not performance critical in something quick and easy and flexible, and then optimize the heck out of the remaining 1% that matters.
(Not a card carrying Python fan or anything, haven't used it in a decade, I just like this architecture.)
> IOW, the question is not whether Python is "fast" or "slow", but whether it is "fast enough" or "too slow" for a given user.
100% this. There isn't REALLY any such thing as good/bad/fast/slow/cheap/expensive, there's just "meets spec better" / "doesn't meet spec as well". Everything is relative to your requirements.
- formerly_proven 5y agoThis works well for applications where you have that kind of split, but there are applications where most of the time is spent scattered around a lot of the code - and if you are in that situation in Python and need to go faster, it's an awkward place to be.
- taneq 5y agoYeah, when none of the code is tight inner loops, all of it is. Not much to do then but reimplement your program in a more efficient language... then call it from a Python script. ;)
- analog31 5y agoI think one thing that makes many Python programs "fast enough" is that people have already provided a huge pile of native objects in the form of the OS and its trimmings. But this is true for other languages as well. If I were writing in C, I'd never try to rewrite any portion of the OS unless I had some otherwise insurmountable issue to overcome. Quite a lot of programs are almost entirely bopping along from one OS or numpy call to the next, with a tiny bit of business logic thrown in. You've got a better chance of making your users happy by thinking about that business logic at a high level, than trying to optimize code that's only doing 1% of the actual work. My use for compiled code is when there's no OS, and every nanosecond matters, e.g., working with microcontrollers.