7 ms·
This is a terrible article. How this has gotten this kind of traction is unexplainable to me. >This is the program I will be using for demonstration purposes
by andrepd 7y ago
This is a terrible article. How this has gotten this kind of traction is unexplainable to me.
>This is the program I will be using for demonstration purposes
>Never comes up again for the rest of the post.
???
>Let's show you how to profile code.
>Also, here's a bunch of unprofiled suggestions with such precise and helpful comments as "slow" and "fast".
?????
>Python haters always say, that one of reasons they don't want to use it, is that it's slow. Well, whether specific program - regardless of programming language used - is fast or slow is very much dependant on developer who wrote it and their skill and ability to write optimized and fast programs.
This is so ridiculous it's honestly laughable.
It's such an obvious falsehood that the only explanations is either the person is truly this clueless, or else they are wilfully spewing bullshit. A bare metal language like C/C++ will of course let you do things faster than a heavy dynamic language like Python.
The mental gymnastics people do to justify not learning another tool.
You know what they say, if all you have is a hammer, everything looks like a nail.
>First rule of optimization is to not do it.
If this person is representative, this explains why computers are hundreds of times faster but most software feels slower than in 1999.
- umvi 7y agoI was rubbing my hands together thinking "oh boy, I already know about speeding up with PyPy, I wonder what other tricks I don't know?" The article was sorely disappointing. > So, let's prove some people wrong and let's see how we can improve performance of our Python programs and make them really fast! > [sets the stage with a program that takes 11 seconds to run] > This is more about general ideas and strategies, which when used, can make a huge impact on performance, in some cases up to 30% speed-up. ...that's it? up to 30% speed-up is "blazingly fast"? On a program that takes 11 seconds to run, that still takes 8 seconds... I was expecting speed-ups that took execution to milliseconds or microseconds.
- cferr 7y agoSeeing as the interpreter takes about 60-70 ms to just start up and do nothing, I don't think we're going to be seeing any benchmarks in the microseconds. $ time python -c pass real 0m0.062s user 0m0.011s sys 0m0.042s That was the quickest of three runs on one of my servers.
- zamfi 7y agoWhat's going on with your server? My 11-year-old Mac Pro runs python in 32 ms! Kidding aside, even just running an empty C program that does nothing still takes 5ms, so not just a Python problem...
- overcast 7y agoTitle buzzword optimization, people upvote things without reading any further than the link name.
- weberc2 7y agoFWIW, I upvote things like this on occasion because I often learn more from comments/debate on articles I disagree with than from those that I solidly agree with already. Sadly HN's ability to have productive debate seems to be in decline, but that's another topic.
- hogFeast 7y agoI don't know why but Python attracts some real zealots. I think everyone has had this conversation about Python's speed with someone (I have, unfortunately, had it many times)...if your program is slow, it is always your fault, Python is perfectly optimised and there is no reason to use any other language...I don't get it. Why does Python need to be all things to all people (srs, I want to understand)?
- weberc2 7y agoPerhaps Python doesn't need to be all things to all people, but it does need to be performant because people really shouldn't start projects with Python unless they are sure their project will never have performance requirements that Python can't deliver on, and they understand the limits of the "just rewrite it in C!" or "just use multiprocessing!" advice. Since it's generally unpredictable whether a project's performance requirements will exceed Python's ability or whether the eventual bottlenecks will be amenable to the aforementioned advice, using Python is generally a bad idea; however, many people don't understand the significant caveats to C/multiprocessing and therefore continue to happily start projects in Python (and paint themselves into corners that are expensive to back out of).
- Accujack 7y ago>If this person is representative, this explains why computers are hundreds of times faster but most software feels slower than in 1999. I think they are representative of a lot of developers. With the continued pace of chip development for the last 35 years, there hasn't been a continuing need to program for performance - in general, unless programmers did something very dumb or were dealing with large amounts of data, they could just write the way they wanted and let the hardware handle making their program fast. Contrast this with early computer games - to get the best performance some games would actually boot your computer without an OS, sacrificing some convenience to get the last few percent of speed needed out of the system because it was the only way to out perform the competition. One reason there's such opportunity in the present state of CPU technology (clock speeds have halted at about 4 Ghz in favor of more cores) is that few people remember how to program for performance, and those that do are handicapped by a bloated OS built for profit rather than value.
- ddalex 7y agoThe real reason is in numbers - how many people that could program a PC starting from bootstrap in assembly are out there, and again how many programmers that can paste Java(EE|script)? code together to make something work are out there? The world needs tons of software, and the vast majority of that software just needs to do some things right some of the time, and an average Java EE developer toiling away in a cubicle is good enough to deliver it. Writing efficient software is a HARD problem, and it doesn't make economical sense to actually write efficient software, it makes sense to write just good enough software and throw hardware at it. For the price of a developer-year you can provision hundreds of machines to run that piece of code.
- bilekas 7y ago> The mental gymnastics people do to justify not learning another tool. You know what they say, if all you have is a hammer, everything looks like a nail. This is so important to listen to . Some people just can't accept there is a right tool for a job. And filling that hammer down to a needle is not something to be proud of.