[Tutor] optimization: faster than for

elis aeris hunter92383 at gmail.com
Mon Jul 2 08:47:02 CEST 2007


> >> In [4]:import array
> >> In [5]:def f7(list):
> >>    .5.:  return array.array('B', list).tostring()
> >>    .5.:
> >>
> >> In [6]:f7([97, 98, 99])
> >> Out[6]:'abc'




ugh the code it self is not generic python,  that was an example of how to
do this


my project is OCR
http://www.eternite.co.uk/gundam_clips/ocr.PNG

The letter I equals to "282" because it has 2 points on the y axis of the
first point, and 8 points on the y axis on the second, and then 2 on the
last one.


So the string would be translated into:

28201722030033330000004222400722240172206 and so on.

#####################


so what I am going to have is a string like above and what I 'll have is

a list of tuples, for instance   [a, 222] , [b,333]  and so forth

how do I write the fastest code to do this



optimization is immediately needed because the job is done as soon this
translation is complete.


so two bottle neck

image.getdata()  is a good solution, i haven't found a better one,

and the other bottle neck is this translation process.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070701/7dd60a8f/attachment.htm 


More information about the Tutor mailing list