[Tutor] How to speed up input/string parsing ...
Kent Johnson
kent37 at tds.net
Thu Sep 27 12:38:30 CEST 2007
Aditya Lal wrote:
> def rev(n) :
> m = 0
> while n > 0 :
> m = m*10 + n%10
> n = n/10
> return m
I would try reversing the numbers as strings. s[::-1] will reverse a
string s.
> How do I improve the input reading or string parsing ? I know there
> should be a better way because the best program (at cost of memory)
> performs > 50% faster than mine. So he must have done something to
> improve input processing.
The programs that use a lot of memory are using psyco.
Kent
More information about the Tutor
mailing list