[Bf-python] svg2obj script.

Martin Poirier theeth at yahoo.com
Thu Mar 29 14:55:44 CEST 2007


--- jmsoler at free.fr wrote:

> Selon jmsoler at free.fr:
> 
> > Selon jmsoler at free.fr:
> >
> > > Selon jmsoler at free.fr:
> > >
> > > > ok, i will post a 059a soon...
> > > >
> > > > jms
> > >
> > > hum,
> > > it seems that something in these changes make
> the script fail
> > > in some cases.
> > >
> > > Traceback (most recent call last):
> > >   File "svg2obj_059a.py", line 1356, in
> functionSELECT
> > >   File "svg2obj_059a.py", line 1331, in
> scan_FILE
> > >   File "svg2obj_059a.py", line 1298, in
> build_HIERARCHY
> > >   File "svg2obj_059a.py", line 871, in
> draw_line_l
> > > ValueError: invalid literal for float():
> -0.085-0.396
> >
> >
> > More exactly, the problem was already in the 059
> version.
> >
> >
> 
> A "not"  was missing in the lines :
>  i = ndata.find('-')
>  if i != -1 and ndata[i-1] not in ' ,e':
> 
> I also did a lot of tests and it seems that this
> code, at least in this
> script,  is often slower than :
> 
> if ndata.find('-')!=-1 and ndata[ndata.find('-')-1]
> not in [' ', ',', 'e']:

You're sure it's that single if that causes the slow
down?

I did some benchmarks with different size strings and
the first version (with the split find) is always
faster.

But even on large strings, the execution time
difference was between 3.60951423645e-06 and
5.2826166153e-06 seconds.

Martin


 
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/



More information about the Bf-python mailing list