ntpviz - Don't plot a line during data absence
Achim Gratz
Stromeko at nexgo.de
Sun Oct 23 19:16:00 UTC 2016
Gary E. Miller writes:
> So, two float conversions per cycle. If C you would do this to
> change a float to a store to make it much faster:
>
> # a is a string of the current time, b is a float of the last time
> # c is a float of the current time
> c = float (a )
> if 1024 < ( c - b):
> # do something
> b = c
>
> In C that would be much faster, but in Python it is slower! In Python
> it seems to be slower to create a new variable than to convert a string
> to a float.
So don't create and destroy variable c each time round your loop.
Create it once outside the loop and use it for assignment inside the
loop and you might see the expected speedup. Or not, depending on how
clever Python gets when it sees that you use the same expression
multiple times on the same argument.
I'm sure Python has ways to just read in all that data into a float
array before you dive into the looping business. You'd generally be
much better off using such a facility if it exists instead of trying to
parse the data file line by line.
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra
More information about the devel
mailing list