[flagged]
How many lines of C it takes to execute a + b in Python
101–110 of 224 posts
Re: How many lines of C it takes to execute a + b in Python
#102[flagged]
Talking about annoying ... I open a HN discussion about an article, and the first comment talks about popups, colours, fonts, cookies, ... and it triggers a long discussion. Same story again and again ... ... now, that's annoying.
> Eschew flamebait. Avoid generic tangents. Omit internet tropes.
> Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something.
> Please don't pick the most provocative thing in an article or post to complain about in the thread. Find something interesting to respond to instead.
> Please don't complain about tangential annoyances—e.g. article or website formats, name collisions, or back-button breakage. They're too common to be interesting.
If we're consistent enough about this, eventually the community will get the message.
Re: How many lines of C it takes to execute a + b in Python
#103Earlier quoted context omitted.
This may be a somewhat uninformed opinion, but I think CPython is just straight up not particularly good software. There are a million and one optimizations that other major scripting runtimes (V8, LuaJIT, PyPy, Ruby YJit etc.) have had for years that CPython is lacking. This is by design though. CPython has never been focused on performance, that's why it's not even JIT. It optimizes for simplicity and easy interope…
The last couple of CPython versions have had dramatic speed improvements, so that demonstrates your point but also gives some hope that things are changing on that front.
Compared to JS pre-and-after modern engines it's a tiny improvement.
Re: How many lines of C it takes to execute a + b in Python
#104Earlier quoted context omitted.
Rust is doing something even more subtle here than just making the hash function a container property. There are two inter-related Rust traits, Hash is a trait which types implement to explain abstractly how to hash that type, but it's written in terms of a Hasher trait so you can drop in a different function with the same API. The Rust standard library provides a derive macro for Hash, so most people can just gestur…
We can get into the weeds about the details, but what I'm talking about is mostly that in Python (and in most languages really, AFAIK Ruby, Java, or C# are the same to list just a few) objects have to return the hash itself, so the hash function is fixed by the type. In Rust, the Hash trait is only used to feed data to a hasher such that the type can decide what should be hashed. The creation of the hasher is done by…
Re: How many lines of C it takes to execute a + b in Python
#105A while back someone posted their patch to cpython where they replaced the hash function with a fast one and claimed this dramatically sped up the whole Python runtime. They claimed that the hash function was used constantly —e.g. 11 times in print("hello world")—because it's used to look up object properties. Apparently the default implementation is not optimized for performance but for security, just in case the so…
This is most effective for reducing startup time of short lived scripts, where the runtime is dominated by many thousands of trivial mallocs right at startup. But in general if you can establish a bound on memory, it will be faster to allocate it in one shot.
Re: How many lines of C it takes to execute a + b in Python
#106Earlier quoted context omitted.
Talking about annoying ... I open a HN discussion about an article, and the first comment talks about popups, colours, fonts, cookies, ... and it triggers a long discussion. Same story again and again ... ... now, that's annoying.
Flag and move on: > Eschew flamebait. Avoid generic tangents. Omit internet tropes. > Please don't post shallow dismissals, especially of other people's work. A good critical comment teaches us something. > Please don't pick the most provocative thing in an article or post to complain about in the thread. Find something interesting to respond to instead. > Please don't complain about tangential annoyances—e.g. articl…
> Click on its timestamp to go to its page, then click the 'flag' link at the top.
The extra click is probably why it isn't used much. I thought I simply didn't have enough karma.
Re: How many lines of C it takes to execute a + b in Python
#107Earlier quoted context omitted.
It's not about what, it's about when though — like the GP, I got a pop-up fairly immediately before I'd engaged in the article so I just closed the tab. The best time to engage me is after I've enjoyed the article and hopefully interested to hear more from the writer rather than immediately landing on the page. It's the equivalent to sales staff jumping on customers in shops the minute they walk in the door — "can I…
"I would rather not read this article than have to click a button" is an interesting level of entitlement. Hope you never had your fingers stained by the ink when reading the newspaper, you probably would have sued the New York Times.
Re: How many lines of C it takes to execute a + b in Python
#108Python'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.
Re: How many lines of C it takes to execute a + b in Python
#109Earlier quoted context omitted.
The semantic issues of making a performant Python language implementation are more or less exactly the same as for JS and Lua, optimizing Ruby seems to possibly have even more "magic" that needs patching but we've seen the Shopify team get cracking on that (it includes MaximeCB that did HiggsJS). PyPy is in many aspects to be rated as a research project that tried a novel approach to reduce the workload compared to t…
Unfortunately Python's innard is much more complicated than most expectations. You have named JS and Lua, but those languages never have "magic" methods---JS instead has prototypes and more recently proxies, while Lua has metatables. Ordinary objects aren't magic in this sense, and conversely magical objects are generally deliberate choices in those languages. But Python's magic `__dunder__` methods are everywhere in…
Re: How many lines of C it takes to execute a + b in Python
#110Earlier quoted context omitted.
This may be a somewhat uninformed opinion, but I think CPython is just straight up not particularly good software. There are a million and one optimizations that other major scripting runtimes (V8, LuaJIT, PyPy, Ruby YJit etc.) have had for years that CPython is lacking. This is by design though. CPython has never been focused on performance, that's why it's not even JIT. It optimizes for simplicity and easy interope…
I don't disagree with you but, now you can retrofit a JIT into python. https://blog.pyston.org/2022/09/29/announcing-3-7-3-10-suppo...
To compare with Javascript: if I remember, as it appeared, V8 JIT was orders of magnitude faster, compared to the interpreted code.