[flagged]
How many lines of C it takes to execute a + b in Python
111–120 of 224 posts
Re: How many lines of C it takes to execute a + b in Python
#112A 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 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…
NumPy, SciPy, TensorFlow, PyTorch, JAX, Pandas, Pillow, lxml, cjson, PyCapnP, Tornado, fast-avro, etc. all get it right. They are wrappers around C (or in some cases: Fortran/assembly/CUDA) code, where the overflow of Python method dispatch is dwarfed by the hundreds of thousands of iterations of an inner loop that's in optimized, vectorized assembly. Django, Protobufs, and Avro get it wrong (often for portability or developer velocity sake), where they wrote the whole library in Python at the expense of performance.
I was briefly tempted to write an API-compatible reimplementation of Django with the core in C++ when I left Google, but by then Django (and server-side web programming) was already falling out of favor, and if you're just shipping JSON to a SPA you can use cjson with any number of fast wsgi or asgi gateways.
Re: How many lines of C it takes to execute a + b in Python
#113Earlier quoted context omitted.
If this is by design and it optimizes for simplicity and easy interoperability with C, why would you assess its quality as 'good software' based on criteria that are non-goals?
In my eyes, "good software" does not necessarily just mean something that accomplishes its goals. You can set a goal of being bad, and that's kind of what CPython is doing. Of course, "good" and "bad" are relative. If you don't care about performance then there's nothing wrong with CPython.
I mean one doesn't need more than:
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
to see. They have that special handling, but they still don't want to let you out, because... IMO, they just want to be annoying.When a solution could be something like:
Note: exit() is needed in scripts. In this prompt Ctrl-D (i.e. EOF) can also be used.
Exiting.Re: How many lines of C it takes to execute a + b in Python
#114Re: How many lines of C it takes to execute a + b in Python
#115A 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…
If I know anything about programmers, it's that everyone would just use the "go faster" flag by default.
Re: How many lines of C it takes to execute a + b in Python
#116The actual posts are here: https://snarky.ca/tag/syntactic-sugar/ (multiple pages!)
Re: How many lines of C it takes to execute a + b in Python
#117Earlier quoted context omitted.
"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.
Dude we had a whole web browser revolution in the early 2000s centered largely around the ability to prevent browser pop-up windows. The fact that people are doing it in the canvas now doesn't suddenly make it not incredibly obnoxious. Pop-up windows were bad design 20 years ago and they're bad design now.
Re: How many lines of C it takes to execute a + b in Python
#118Earlier quoted context omitted.
In my eyes, "good software" does not necessarily just mean something that accomplishes its goals. You can set a goal of being bad, and that's kind of what CPython is doing. Of course, "good" and "bad" are relative. If you don't care about performance then there's nothing wrong with CPython.
I agree with that estimate, I think it was really the idea of Python to be less than "good" by design. I mean one doesn't need more than: >>> exit Use exit() or Ctrl-D (i.e. EOF) to exit to see. They have that special handling, but they still don't want to let you out, because... IMO, they just want to be annoying. When a solution could be something like: Note: exit() is needed in scripts. In this prompt Ctrl-D (i.e.…
Re: How many lines of C it takes to execute a + b in Python
#119A more interesting example IMO would be something like "how many lines of C it takes to execute person.name='Bob' in Python, where person.name is undefined".
That would better demonstrate why we use Python in the first place (hint: it's not "to add integers"), while also indicating why it is slow.
Re: How many lines of C it takes to execute a + b in Python
#120Earlier quoted context omitted.
Dude we had a whole web browser revolution in the early 2000s centered largely around the ability to prevent browser pop-up windows. The fact that people are doing it in the canvas now doesn't suddenly make it not incredibly obnoxious. Pop-up windows were bad design 20 years ago and they're bad design now.
Pop-up windows that take focus over other running applications are a whole another ball game, dude. In-app popups are a pattern that may or may not be annoying, like most things used well or badly. This case seems pretty innocuous to me.