[PyKDE] Qstring problem
Detlev Offenbach
detlev at die-offenbachs.de
Tue Mar 1 14:12:59 GMT 2005
Am Dienstag, 1. März 2005 14:44 schrieb Flávio Codeço Coelho:
> On Tuesday 01 March 2005 10:16, Hans-Peter Jansen wrote:
> > Try e.g.:
> > int(QLineEdit.text().latin1())
> > or:
> > int(str(QLineEdit.text()))
> >
How about using QLineEdit.text().toInt() ?
Detlev
> > In return it would be nice to time the variants and let us know the
> > results.
>
> Thanks Jorge and Hans,
>
> and as requested by Hans, here are the timings:
>
> Code:
> from qt import *
> a = QString('123')
> for i in range (10000):
> int(str(a))
>
>
> In [4]: run -p teste.py
> 3 function calls in 0.020 CPU seconds
>
> Ordered by: internal time
>
> ncalls tottime percall cumtime percall filename:lineno(function)
> 1 0.020 0.020 0.020 0.020 teste.py:1(?)
> 0 0.000 0.000 profile:0(profiler)
> 1 0.000 0.000 0.020 0.020 <string>:1(?)
> 1 0.000 0.000 0.020 0.020 profile:0
> (execfile(filename,prog_ns))
>
>
> and for the latin1():
>
> Code:
> from qt import *
> a = QString('123')
> for i in range (10000):
> int(a.latin1())
>
>
> In [6]: run -p teste.py
> 3 function calls in 0.040 CPU seconds
>
> Ordered by: internal time
>
> ncalls tottime percall cumtime percall filename:lineno(function)
> 1 0.040 0.040 0.040 0.040 teste.py:1(?)
> 0 0.000 0.000 profile:0(profiler)
> 1 0.000 0.000 0.040 0.040 <string>:1(?)
> 1 0.
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the PyQt
mailing list