News for hackers. Stuff that matters.
Re:Do you know how much your computer can do in a second? by ProblemFactory on Sunday October 25, 2015 @09:37AM (#10446834)
It runs at 1/10 speed because it's interpreted bytecode, and it allocates a new PyInt object for each number in the loop.

You can get it back close to native speed by adding a type annotation and compiling the python file with Cython: http://docs.cython.org/src/userguide/language_basics.html#in...

    def f(NUMBER):
        cdef int i
        for i in range(NUMBER):
            pass
Re:Do you know how much your computer can do in a second? by andreasvc on Sunday October 25, 2015 @11:08AM (#10447056)
Not just close to native speed, this will get you the exact same C code for the inner loop.