[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Game Objects 0.0.2



On Sun, 17 Jun 2007, Richard Jones wrote:
> I presume you were just calling float(value)? I'm surprised that is slower
> than invoking isinstance() if value is a float.

And a quick check tells me my gut was about right: there is no time difference 
between these if value is a float:

$ python -m timeit 'isinstance(1.0, float)'
1000000 loops, best of 3: 0.34 usec per loop
$ python -m timeit 'float(1.0)'
1000000 loops, best of 3: 0.344 usec per loop

Of course your code uses an assert for the isinstance which will be removed 
when Python's invoked with "-O"...


   Richard