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

Re: [pygame] Game Objects 0.0.2



On Sun, 17 Jun 2007, Will McGugan wrote:
> Marius Gedminas wrote:
> >I'm somewhat surprised that your r/g/b/a setters perform an isinstance
> >check and explicitly require a float.  What's wrong with accepting ints
> >(0 or 1)?
>
> I want to use floats internally, so that it will always use float
> arithmetic. I _could_ simply wrap the setter value with float(), but
> that would leed to the situation where you could do col.r = "20" - which
> is just wrong. Coercing to a float also turned out to be comparatively
> slow in my tests.

I presume you were just calling float(value)? I'm surprised that is slower 
than invoking isinstance() if value is a float.


    Richard