Honestly for a language that’s supposed to be simple and easy to use Python seems really complicated and hard to understand. Anything big or performance critical should probably not be written in Python - and yet people are doing it. And then we end up with a house of cards with this project built on top of the very shaky foundation of mypy.
You Should Compile Your Python and Here’s Why
81–90 of 109 posts
Re: You Should Compile Your Python and Here’s Why
#82"Python is Slow, And That's Fine, Because It's Fast Enough" At least this is honest. No matter what the script does, no matter how fast the libraries, the Python intepreter has a slow startup time. On multiple occasions I have seen people commenting on HN argue that Python is not slow. I think for these commenters Python is "fast enough". For others, like me, it may not be "fast enough". IOW, the question is not whet…
I don’t always know how fast will be fast enough when I start a project and the risk of needing a rewrite really puts me off Python.
Re: You Should Compile Your Python and Here’s Why
#83Earlier quoted context omitted.
> the Python intepreter has a slow startup time. This really depends on your perspective. Sure, it's a lot slower than running a native binary. But it's still fast enough for interactive tools that you run often. If you compare that to java tools, for example, which take seconds if not dozens of seconds to start (gradle, I'm looking at you!), python is far better.
> it's still fast enough for Interactive tools that you run often. Oh really? https://www.mercurial-scm.org/wiki/OxidationPlan > chg's very existence is because we need hg to be a native binary in order to avoid Python startup overhead. If hg weren't a Python script, we wouldn't need chg to be a separate program.
Re: You Should Compile Your Python and Here’s Why
#84"Python is Slow, And That's Fine, Because It's Fast Enough" At least this is honest. No matter what the script does, no matter how fast the libraries, the Python intepreter has a slow startup time. On multiple occasions I have seen people commenting on HN argue that Python is not slow. I think for these commenters Python is "fast enough". For others, like me, it may not be "fast enough". IOW, the question is not whet…
Re: You Should Compile Your Python and Here’s Why
#85Earlier quoted context omitted.
Reminds me of that Tao of Programming koan (if I remember it rightly) that went something like: The novice, in his frustration, struck the side of his computer. The master walked over and asked what he was doing. The novice exclaimed, "my computer is not working and I do not know why!" The master admonished him, saying "you cannot solve the problem by striking the computer without knowing what is wrong." Then the mas…
It was one of the AI koans in Jargon: > A novice was trying to fix a broken Lisp machine by turning the power off and on. > Knight, seeing what the student was doing, spoke sternly: “You cannot fix a machine by just power-cycling it with no understanding of what is going wrong.” > Knight turned the machine off and on. > The machine worked.
Re: You Should Compile Your Python and Here’s Why
#86I've been writing some python the last few days. Today I did something terrible. I like to believe it was out of wisdom rather than ignorance. I needed to do some nuanced bit manipulations, and so I built up a string of ascii 0's and 1's, sliced the string, and then converted back to integers. I worked on a codebase many years ago when I was an intern. That code would read frames off a CAN bus in a car. For some reas…
Reminds me of that Tao of Programming koan (if I remember it rightly) that went something like: The novice, in his frustration, struck the side of his computer. The master walked over and asked what he was doing. The novice exclaimed, "my computer is not working and I do not know why!" The master admonished him, saying "you cannot solve the problem by striking the computer without knowing what is wrong." Then the mas…
Re: You Should Compile Your Python and Here’s Why
#87Earlier quoted context omitted.
I don’t always know how fast will be fast enough when I start a project and the risk of needing a rewrite really puts me off Python.
I work in python all the time, and I’ve still not found a situation where this happened. Sometimes you might have specific components that you might want to write in other languages, but this is really rare unless you’re manually writing really computationally intensive or time critical procedures. Which hopefully you should know going into the project. Like if you’re rolling your own in-line audio processing you kno…
Re: You Should Compile Your Python and Here’s Why
#88Earlier quoted context omitted.
> it's still fast enough for Interactive tools that you run often. Oh really? https://www.mercurial-scm.org/wiki/OxidationPlan > chg's very existence is because we need hg to be a native binary in order to avoid Python startup overhead. If hg weren't a Python script, we wouldn't need chg to be a separate program.
god I love Hg over git. I don't understand why git is more popular.
Re: You Should Compile Your Python and Here’s Why
#89I'm learning Python. Do someone knows a resource to learn the well-known tricks for "fast" Python? A book, a website, a cheat sheet or even a MOOC or part of a MOOC?
There are plenty of things for which python is not slow, but people using python don't know a lot about programming, and end up with a slow result. A couple of advises: - the right algo will go a long, long way. - know your data structures. E.G: assigning to a slice is ridiculously fast (even while unpacking), memory views may save a lot on byte heavy workloads, heapq and deque are underrated, etc. Also check out htt…
Do you have any numbers to back this up? Why would Pathlib be slow?
Re: You Should Compile Your Python and Here’s Why
#90Earlier quoted context omitted.
This is premature optimization right
Yes and no. One of the biggest disadvantages of python is that the way people typically optimize python code is to 1. rewrite in numpy 2. rewrite in Cython (or other python compiler) 3. rewrite in C++ The problem with this workflow is that it means you end up rewriting large chunks of your code over several years in systems that have fairly different idioms. If you suspect you might in the future be performance bottl…