Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
>> 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_

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Eike Welk
On Sunday 01 July 2007 23:53, Alan Gauld wrote: > "elis aeris" <[EMAIL PROTECTED]> wrote > > >> 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' > > I can't remember which tool does

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread elis aeris
uh, can i ask about something very quickly? how do i write a function to do a pop up window with designated window name, type (ok, cancel, those) and message? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread Reed O'Brien
On Jul 1, 2007, at 6:38 PM, ALAN GAULD wrote: > Suddenly it seems like I have an embarassment of advanced > shells to choose from. At risk of starting a religious war, who > favours which and why? > > Alan, I have been using ipython for the last few months. I am barely touching teh surface o

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread Reed O'Brien
On Jul 1, 2007, at 7:13 PM, elis aeris wrote: might just end my quest for optimized python source code. ugh, what does it mean ? elias, We have two MAJOR rules regarding optimization. These rules really go beyond python, but this is a good place to learn them. The two rules of optimi

[Tutor] put data from text file into list

2007-07-01 Thread Mike Hoy
is it possible to take information contained inside a text file and put it into a list? My text file contains info derived from a list so it looks like this: ['foo','bar']. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread elis aeris
http://memoryhacking.com/forums/viewtopic.php?p=1195#1195 On 7/1/07, Alan Gauld <[EMAIL PROTECTED]> wrote: "elis aeris" <[EMAIL PROTECTED]> wrote > Use the best for-equivalent and run the code below, Elis, Can you tell us what exactly you are trying to do? I'm not sure whether its just

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris
oh i want to bring something up, there is this one line which i think is suggesting that there is a way to use this object that the document says it's a lot faster than getdata and getpixel. *im.load()* Allocates storage for the image and loads it from the file (or from the source, for lazy op

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote > Use the best for-equivalent and run the code below, Elis, Can you tell us what exactly you are trying to do? I'm not sure whether its just running tests on loop contructs or trying to get a list of pixels from an image (and if so to do what with them?)

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris
in that case, can we talk about what this is? import array def f7(list): return array.array('B', list).tostring() f7([97, 98, 99]) Out[6]:'abc' It's only one line, and it's faster than for(), getting through this one might just end my quest for optimized python source code. (then i ll be

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote > so, i should look into ipython's doc for this code? No, Ipython is just another shell, like IDLE. Its not a different version of python, it just displays its prompts differently is all. Alan G. ___ Tutor mail

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread Kent Johnson
elis aeris wrote: > no, this one: > > > > 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' That has nothing at all to do with reading lines of a file. It is the fastest way to solve one particu

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread Kent Johnson
ALAN GAULD wrote: > In [6]:f7([97, 98, 99]) > Out[6]:'abc' >>> I can't remember which tool does this - IronPython maybe? >> It's IPython -- http://ipython.scipy.org/moin/ > > Now for some reason I assumed IPython was the IDE for IronPython. > Having checked out the web link its obviously c

Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread elis aeris
Oie, as if the battle for the best text editor is not enough ... Well, can you run a test for me? Use the best for-equivalent and run the code below, instead of 1024*768, scale to 800*600 , just so the window you are screen shotting from is small enough. import time import ImageGrab

[Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread ALAN GAULD
> > >> In [6]:f7([97, 98, 99]) > > >> Out[6]:'abc' > > I can't remember which tool does this - IronPython maybe? > > It's IPython -- http://ipython.scipy.org/moin/ Now for some reason I assumed IPython was the IDE for IronPython. Having checked out the web link its obviously completely unrelated!

Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
of course. but i tried only the code, not rewriting the pixelget part into that, because I have to understand it first. so, i should look into ipython's doc for this code? ok, import array def f7(list): return array.array('B', list).tostring() f7([97, 98, 99]) Out[6]:'abc' searching with

Re: [Tutor] optimization: faster than for

2007-07-01 Thread John Fouhy
On 02/07/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > "elis aeris" <[EMAIL PROTECTED]> wrote > > >> 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' > I can't remember which tool do

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Luke Paireepinart
elis aeris wrote: > my reply > oh crancky! C# ! > > http://en.wikipedia.org/wiki/Iron_Python > > i better try to find the best way to do it with the official python > genre before venturing into that world of pain without PIL ! Please don't reply directly to me. Iron Python is an implementatio

Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
my reply oh crancky! C# ! http://en.wikipedia.org/wiki/Iron_Python i better try to find the best way to do it with the official python genre before venturing into that world of pain without PIL ! Quote:- Hide quoted text - In [4]:import array In [5]:def f7(list): .5.: return arra

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread Luke Paireepinart
elis aeris wrote: > I found out that by making a copy of it, it can be load() ed ! ImageGrab returns an image instance. You can get the pixel data directly using getdata(). There's no reason to do what you're doing. -Luke ___ Tutor maillist - Tutor@pyt

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Luke Paireepinart
elis aeris wrote: > oh crancky! C# ! > > > i better try to find the best way to do it with the official python > genre before venturing into that world of pain without PIL ! What are you talking about. ___ Tutor maillist - Tutor@python.org http://ma

Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
oh crancky! C# ! i better try to find the best way to do it with the official python genre before venturing into that world of pain without PIL ! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote >> 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' I can't remember which tool does this - IronPython maybe? but the Ins are Inputs, the numbers aret

Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
oh i get it, it's line number. import array def f7(list): return array.array('B', list).tostring() f7([97, 98, 99]) ## NOW, this looks python ! ___ Tutor maillist - Tutor@python.org http://mail.pyt

Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
so this is the actual code? [4]:import array [5]:def f7(list): .5.: return array.array('B', list).tostring() .5.: [6]:f7([97, 98, 99]) Output on the screen: [6]:'abc'- Hide quoted text - ___ Tutor maillist - Tutor@python.org http://mail.pytho

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Luke Paireepinart
elis aeris wrote: > ugh, can someone who is online at this time give me some pointers on > how to read this? > > i don't know how to look it up, > > in is listed, > out is not, so i am not sure if this is python at all. IN is what you INput into the python interpeter. OUT is what the interpreter O

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris
I found out that by making a copy of it, it can be load() ed ! it runs 3 times faster now import time import ImageGrab from ctypes import * class RECT(Structure): _fields_ = [ ('left', c_ulong), ('top', c_ulong), ('right', c_ulong), ('bottom', c_ulong) ] GetFor

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris
The for version, as claimed by http://www.python.org/doc/essays/list2str.html The fastest version of the algorithm is this one: 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' ___

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris
no, this one: 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' ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread Robert Hicks
Alan Gauld wrote: > "Robert Hicks" <[EMAIL PROTECTED]> wrote >> This is the loop code: >> >> for line in f2: >> for id in idList: >> if id in line: >> print "%s: %s" % (id, f2.next()) >> found = "%s: %s" % (id, f2.next()) >> f3.write(found) >> > > W

Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris
ugh, can someone who is online at this time give me some pointers on how to read this? i don't know how to look it up, in is listed, out is not, so i am not sure if this is python at all. On 7/1/07, Eike Welk <[EMAIL PROTECTED]> wrote: On Sunday 01 July 2007 06:17, elis aeris wrote: > The for

Re: [Tutor] im.getdata()

2007-07-01 Thread Roel Schroeven
elis aeris schreef: > > > I am capturing a screen shot, but then the image was already > > > image, how do I .load it ? > > it's not image.load() I see. In that case, you can't use the method I described; that only works if you load the image from disk (as far as I know). I think you'd

Re: [Tutor] im.getdata()

2007-07-01 Thread elis aeris
I am capturing a screen shot, but then the image was already image, how do I .load it ? it's not image.load() import time import ImageGrab # Part of PIL from ctypes import * class RECT(Structure): _fields_ = [ ('left', c_ulong), ('top', c_ulong), ('right', c_ulong), ('botto

Re: [Tutor] im.getdata()

2007-07-01 Thread Roel Schroeven
elis aeris schreef: > Googling "PIL Handbook" yields this page > http://www.pythonware.com/library/pil/handbook/image.htm > > and, as I said, > """ > > > getdata > > *im.getdata()* => sequence If you're using PIL >= 1.1.6, there's

Re: [Tutor] write a movie file thumbnail in Linux...

2007-07-01 Thread Luke Paireepinart
Eric Walstad wrote: > Hi all, > > Nautilus does it when I browse to a directory that contains images and > movie files created with my digital camera. I see thumbnails of the > image (jpeg) and the movie (mov) files. > > I use python to process (rename, make reduced resolution copies (PIL)) > of m

[Tutor] write a movie file thumbnail in Linux...

2007-07-01 Thread Eric Walstad
Hi all, Nautilus does it when I browse to a directory that contains images and movie files created with my digital camera. I see thumbnails of the image (jpeg) and the movie (mov) files. I use python to process (rename, make reduced resolution copies (PIL)) of my image files. I'd like to also h

Re: [Tutor] 200 dollar questions!

2007-07-01 Thread Eike Welk
On Sunday 01 July 2007 05:30, elis aeris wrote: > Yes, I am trying to write a OCR algorithm with neural network, but > the theories of NN is of little importance, what I am trying to get > ready for the project is run speed. If you do serious image analysis you should maybe switch to NumPy and Sc

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Eike Welk
On Sunday 01 July 2007 06:17, elis aeris wrote: > The for version, as claimed by > > http://www.python.org/doc/essays/list2str.html The fastest version of the algorithm is this one: In [4]:import array In [5]:def f7(list): .5.: return array.array('B', list).tostring() .5.: In [6]:f7([97,

Re: [Tutor] im.getdata()

2007-07-01 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote > *im.getdata()* => sequence > > Returns the contents of an image as a sequence object > ... > Note that the sequence object returned by this method is an internal > PIL > data type, which only supports certain sequence operations, > including > iteration a

[Tutor] im.getdata()

2007-07-01 Thread elis aeris
Googling "PIL Handbook" yields this page http://www.pythonware.com/library/pil/handbook/image.htm and, as I said, """ getdata *im.getdata()* => sequence Returns the contents of an image as a sequence object containing pixel values. The sequence object is flattened, so that values for line

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Kent Johnson
elis aeris wrote: > x = 0 > y = 0 > for x in xrange(1,1024,1): > for y in xrange(1,768,1): > rgb = image.getpixel((10, 12)) > > > > Luke said there is a faster way to do image.getpixel((10, 12)) > > so i am still waiting on that, > > the above has been improved many times and it'

Re: [Tutor] optimization: faster than for

2007-07-01 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote ` > oh yeah, he said getdata() but i don't know where it comes from He told you it was a method of the image... Another version of what you are doing uses a list comprehension which might be slightly faster: pixels = [image.getpixel((x,y)) for x in range

Re: [Tutor] 200 dollar questions!

2007-07-01 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> wrote > import win32ui > window = win32ui.FindWindow(None, "123.txt") > yourwindow.ShowWindow() The title is incorrect. A Notepad window has a title like: 123.txt - Notepad So thats what you need to search for. I told you Windoze APIs were flakey! :-) Alan G