6 ms·
What's the answer?
by ctenb 3y ago
What's the answer?
- a3w 3y agoRunning `__radd__(tyepof(b) b)` on `a` seems like a complicated problem. So: Many LoC? Or, the generic, useless but correct, answer: it depends (as the linked article said, too)
- varjag 3y agoIt shoud've been possible to establish the lower and upper bounds.
- baq 3y agoit's about as possible as solving the halting problem if you allow for operator overloading.
- varjag 3y agoLeaving aside the apparent confusion between C and C++, do you really imply overloading could make adding two fixed size numbers in Python take unbounded time?
- baq 3y agoI'm saying a + b in Python can do whatever you override the __add__/__radd__ to. Not sure why you invoke C/C++ here. If you only limit yourself to numbers (the title doesn't specify that) it should be bounded, but the article goes into some depth here, so I'll leave it at that.
- varjag 3y agoFair!
- FartyMcFarter 3y agoBut this has nothing to do with the halting problem. You can run the code, you don't need to do this theoretically.
- FartyMcFarter 3y agoNo. All you need to do is use a code coverage tool to find out which lines are run.
- andromaton 3y agoArticle does not answer the question on its title.
- Karellen 3y agoIt's hard to say. How many lines of code does it take to call typeobj->tp_as_number->nb_add() when `tp_as_number` is a pointer to a `struct float_as_number`, and `nb_add` is a pointer to `float_add`? Do struct definitions count as "lines of code called"?