Sounds like it would be easier to just use C anyway.
How many lines of C it takes to execute a + b in Python
21–30 of 224 posts
Re: How many lines of C it takes to execute a + b in Python
#22Sounds 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.)
There's a surprising amount of depth to adding two numbers.
Re: How many lines of C it takes to execute a + b in Python
#23Sounds 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
#24Re: How many lines of C it takes to execute a + b in Python
#25Re: How many lines of C it takes to execute a + b in Python
#26Sounds 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.)
You don't event need strings or lists for that. Just imagine bigger numbers for a and b. Arbitrarily long integer addition is not a native language feature in C.
edit: formatting
Re: How many lines of C it takes to execute a + b in Python
#27What's the answer?
Re: How many lines of C it takes to execute a + b in Python
#28Lines of C aren't the defining factor. You want total instructions executed.
Re: How many lines of C it takes to execute a + b in Python
#29Re: How many lines of C it takes to execute a + b in Python
#30Python'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.
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).