no sign() function ?
pdorange at pas-de-pub-merci.mac.com
Wed Dec 24 08:59:16 CET 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
> 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"
More information about the Python-list