Earlier quoted context omitted.
Is there any direct comparison though? Because it can be alternatively argued that these dynamic languages needed new JIT techniques for performance, but they especially work well for more constrained languages like JS. I don't think Smalltalk was ever a good fit for number crunching, for example.
Better than CPython, regardless of how you put it. EDIT: Also to note, those languages powered whole graphical single workstations, with microcoded CPUs + JIT. "Efficient implementation of the smalltalk-80 system" https://dl.acm.org/doi/10.1145/800017.800542 https://computerhistory.org/blog/introducing-the-smalltalk-z... "Self-Confidence: How SELF Became a High-Performance Language" https://www.cs.cornell.edu/courses…
How many lines of C it takes to execute a + b in Python
191–200 of 224 posts
Re: How many lines of C it takes to execute a + b in Python
#192Earlier quoted context omitted.
In the late 1990s and early 200xs, there were a lot of claims that there was no such thing as a "slow language", that all languages can be run as quickly as C if you just built a sufficiently smart compiler and/or runtime. I haven't heard anyone make this claim in a while. The inability to speed up Python beyond a certain point despite a lot of clever approaches taken was probably a good chunk of the reason, the rema…
> In the late 1990s and early 200xs, there were a lot of claims that there was no such thing as a "slow language", that all languages can be run as quickly as C if you just built a sufficiently smart compiler and/or runtime. I think "slow language" never meant that way. It was more like a counterpoint to the claim that there are inherent classes of languages in terms of performance, so that some language is (say) 100…
Maybe if we take the slowest C program, CPython no slower than 50x ?
https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: How many lines of C it takes to execute a + b in Python
#193Earlier quoted context omitted.
You should have added Ruby JITs into the explanation, with the related generated Assembly code. :)
Yeah that would be fun but I don't have a Ruby environment installed and the comment is already getting very long; if I ever turn this into a blog post someday maybe I will add that :)
Re: How many lines of C it takes to execute a + b in Python
#194Python's math operations are going to need a lot of C code because the numbers can be any size. It's part of what makes it so great for scientific computing (as you don't have to spend hours implementing arbitrary precision math - probably badly.) If that's too slow though there's always NumPy.
That's only true for integers. For scientific applications you'd typically want floating points and Python's floats are just regular ieee-754 doubles (or whatever "double" meant to the compiler used to compile that python interpreter).
For example: I do a lot of work with financial software and also some basic applied cryptography. And the essential rule is to never ever use floats. Where 'decimals' are needed you want them to be simulated using integers. Python has a module called decimal which I think helps mitigate some of these issues.
I've written some code to work with accurate, large precision numbers in Python and C before. Mostly the annoying part with this is having data types for the numbers that correspond well to database fields (like uint64) or are portable (in C its easiest if you can get a u128 but this type is very compiler-specific so some hacking may be needed.)
It's fun to work on code like this but definitely needs to be precise and have good test coverage. Writing your own math libraries that are going to be used for such important operations is hair-raising stuff.
Re: How many lines of C it takes to execute a + b in Python
#195Earlier quoted context omitted.
I'd love to see an example of this if you happen to have one available. I hit a startup-time issue in a previous life, and I wish I had spent the time looking at it back then
A template repo can be found here https://github.com/JacksonKearl/cpython , but it does not implement an ideal malloc, just a baseline one - I am not sure if it is still being used as an assignment. The repo states that even this dummy implementation: > has a 60% faster startup as compared to base CPython, and in some test cases has marginally better runtime performance as well.
Re: How many lines of C it takes to execute a + b in Python
#196Earlier quoted context omitted.
> In the late 1990s and early 200xs, there were a lot of claims that there was no such thing as a "slow language", that all languages can be run as quickly as C if you just built a sufficiently smart compiler and/or runtime. I think "slow language" never meant that way. It was more like a counterpoint to the claim that there are inherent classes of languages in terms of performance, so that some language is (say) 100…
> Most languages with enough optimization works can be made performant enough that it's no slower than 10x C. Maybe if we take the slowest C program, CPython no slower than 50x ? https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: How many lines of C it takes to execute a + b in Python
#197Earlier quoted context omitted.
Better than CPython, regardless of how you put it. EDIT: Also to note, those languages powered whole graphical single workstations, with microcoded CPUs + JIT. "Efficient implementation of the smalltalk-80 system" https://dl.acm.org/doi/10.1145/800017.800542 https://computerhistory.org/blog/introducing-the-smalltalk-z... "Self-Confidence: How SELF Became a High-Performance Language" https://www.cs.cornell.edu/courses…
vs CPython https://benchmarksgame-team.pages.debian.net/benchmarksgame/... vs Node https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
Re: How many lines of C it takes to execute a + b in Python
#198Earlier quoted context omitted.
> In the late 1990s and early 200xs, there were a lot of claims that there was no such thing as a "slow language", that all languages can be run as quickly as C if you just built a sufficiently smart compiler and/or runtime. I think "slow language" never meant that way. It was more like a counterpoint to the claim that there are inherent classes of languages in terms of performance, so that some language is (say) 100…
"If you have used Python long enough you may know that Python originally had two types of classes" Yes, because that's also the era where this claim was flying around. I'd say that each individual person may have their own read on what the claim meant, but certainly the way it was deployed at anyone who vaguely complained that Python was kind of slow shows that plenty of people in practice read it as I've described..…
Re: How many lines of C it takes to execute a + b in Python
#199Earlier quoted context omitted.
Also, you have craziness like quite regular iteration being implemented using exceptions, which are not exactly trivial to optimize.
If you want to be return absolutely any value from an iterator, an exception is indeed a reasonable choice though. Python generators came in much later, unlike JS for example.