Earlier quoted context omitted.
It shoud've been possible to establish the lower and upper bounds.
it's about as possible as solving the halting problem if you allow for operator overloading.
How many lines of C it takes to execute a + b in Python
161–170 of 224 posts
Re: How many lines of C it takes to execute a + b in Python
#162Sounds like it would be easier to just use C anyway.
Yes, but C is a much more arcane and complicated language. Case in point: instead of writing a+b in Python, in C you would have to write a+b (Jokes aside, it would really be more complicated in C if a and b were actually strings or lists.)
Re: How many lines of C it takes to execute a + b in Python
#163Earlier quoted context omitted.
It's great software for the use case that Python is intended for . Python is supposed to be glue code. You embed a scripting runtime in your application, do all the heavy lifting in C, but configure your building blocks in Python so that you can easily reconfigure them as needs change. NumPy, SciPy, TensorFlow, PyTorch, JAX, Pandas, Pillow, lxml, cjson, PyCapnP, Tornado, fast-avro, etc. all get it right. They are wra…
> 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. I like Django. I need to process data on the server side and like to write that in python because it is mor…
https://stackoverflow.com/questions/17330158/django-how-to-u...
Re: How many lines of C it takes to execute a + b in Python
#164Earlier quoted context omitted.
> for the use case that Python is intended for Where is this single use case intent articulated, by whom, and what year was it? What is the use case? Today, it seems that Python is pitched for almost everything, short of ethernet drivers.
From https://www.python.org/about/ (mouse over the "About" menu) : 'Python is a programming language that lets you work more quickly and integrate your systems more effectively.'
Re: How many lines of C it takes to execute a + b in Python
#165Earlier quoted context omitted.
> for the use case that Python is intended for Where is this single use case intent articulated, by whom, and what year was it? What is the use case? Today, it seems that Python is pitched for almost everything, short of ethernet drivers.
From https://www.python.org/about/ (mouse over the "About" menu) : 'Python is a programming language that lets you work more quickly and integrate your systems more effectively.'
Re: How many lines of C it takes to execute a + b in Python
#166Earlier quoted context omitted.
It's great software for the use case that Python is intended for . Python is supposed to be glue code. You embed a scripting runtime in your application, do all the heavy lifting in C, but configure your building blocks in Python so that you can easily reconfigure them as needs change. NumPy, SciPy, TensorFlow, PyTorch, JAX, Pandas, Pillow, lxml, cjson, PyCapnP, Tornado, fast-avro, etc. all get it right. They are wra…
> for the use case that Python is intended for Where is this single use case intent articulated, by whom, and what year was it? What is the use case? Today, it seems that Python is pitched for almost everything, short of ethernet drivers.
I think the "Python is pitched for almost everything" in that sentence shows a misinterpretation of gp's phrasing of "use case".
The "use case" isn't about different subject matter domains as if it was a claim about using Python as a universal language for writing database kernels or AAA games.
Instead, the "use case" is about the 2-level 2-language architecture of (1) a high-level scripting language and (2) extension modules that can be written in low-level C and imported into the interpreter. That's the "glue language" + "C Language" to combine the strengths of each language approach. (In contrast, Julia took approach of designing a language that was "fast enough" to avoid the "2 languages issue".)
>Where is this single use case intent articulated, by whom, and what year was it? What is the use case?
The Python "ergonomics use case" (not "domains use case") was originated by Python's inventor Guido van Rossum from the beginning in 1991. A clone of the 1991 Python source code has Guido's commentary for importing C modules:
https://github.com/smontanaro/python-0.9.1
Modern frameworks and libraries like TensorFlow and Pytorch continue the same use case of "high-level script glue code calling low-level C code" that was there in 1991. You can't write a tight cpu loop in pure Python code to paint a 60fps video game. That's not Python's intended use case. That philosophy is why a library like Tensorflow only has Python code for users to "glue" together the neural network graph which then calls out to the C++ code for the expensive cpu loops of backpropagation, gradient descent, etc.
Re: How many lines of C it takes to execute a + b in Python
#167A 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…
Hash function security is certainly a concern due to hash flooding attacks which force worst case performance hash table lookup and leads to denial of service. https://peps.python.org/pep-0456/
Re: How many lines of C it takes to execute a + b in Python
#168Earlier quoted context omitted.
> for the use case that Python is intended for Where is this single use case intent articulated, by whom, and what year was it? What is the use case? Today, it seems that Python is pitched for almost everything, short of ethernet drivers.
>Today, it seems that Python is pitched for almost everything, short of ethernet drivers. I think the "Python is pitched for almost everything" in that sentence shows a misinterpretation of gp's phrasing of "use case". The "use case" isn't about different subject matter domains as if it was a claim about using Python as a universal language for writing database kernels or AAA games. Instead, the "use case" is about t…
Re: How many lines of C it takes to execute a + b in Python
#169A 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…
Re: How many lines of C it takes to execute a + b in Python
#170Earlier quoted context omitted.
I wonder what percent of this audience got the tootsie-roll reference. Does anyone under 40 know it?
I am about to turn 38 and I got it, so it's at least slightly lower than 40.