no sign() function ?
Pierre-Alain Dorange
pdorange at pas-de-pub-merci.mac.com
Wed Dec 24 02:59:16 EST 2008
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> > sign_0 : 0.375
> > sign_1 : 0.444 (+18%)
> > sign_2 : 0.661 (+76%)
> > sign_3 : 0.498 (+33%)
>
>
> Looking at those results, and remembering that each time is for one
> million iterations of one thousand calls each,
one million iteration only, that's enough but yes indeed this function
is fast.
> I'd say that there's so
> little difference in speed between them, that you should choose whichever
> function is easier to understand.
Yes, you're right. I just made those test for pure intellectual reason.
For me sign_0 is the simplest one to understood.
So in the domain of my little arcade game, this is what i'll use.
I don't need the accuraccy of sign_1, because in the application i just
need to know if the target is right or left or if the speed direction is
right or left.
> At least until you profile your
> application and discover that the sign() function is the bottleneck
> keeping your program slow.
In each frame i'll have to use about 10 to 20 sign() call, so it'll not
be the bottleneck.
--
Pierre-Alain Dorange <http://microwar.sourceforge.net/>
Ce message est sous licence Creative Commons "by-nc-sa-2.0"
<http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>
More information about the Python-list
mailing list