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

2007-07-09 Thread Tiger12506
It seems to me that what you need is this. http://www.python.net/crew/mhammond/win32/Downloads.html I think the key that you are missing here is that python does not include functions that you ask without downloading something special. Check the link, download those extensions, and read the docu

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

2007-07-05 Thread Alan Gauld
"elis aeris" <[EMAIL PROTECTED]> >I need some of a something to be imported into python Maybe. > these are the functions I need, anyway know anything that might do > any of > the following? Assuming you are still talking about Windows XP... > suppose the class' name is autowindow: What kind

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

2007-07-05 Thread elis aeris
I need some of a something to be imported into python these are the functions I need, anyway know anything that might do any of the following? Eg: suppose the class' name is autowindow: autowindow.gainfocus(handle) put the window of that handle into focus. import autowindow autowindow.im

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

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] 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] 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] 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] 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] Fastest way to iterate through a file

2007-06-29 Thread Alan Gauld
"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) > While I note that you got a sol

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

2007-06-26 Thread Robert Hicks
Kent Johnson wrote: > Robert Hicks wrote: >> Kent Johnson wrote: >>> Robert Hicks wrote: idList only has about 129 id numbers in it. >>> That is quite a few times to be searching each line of the file. Try >>> using a regular expression search instead, like this: >>> >>> import re >>> regex =

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

2007-06-26 Thread Kent Johnson
Robert Hicks wrote: > Kent Johnson wrote: >> Robert Hicks wrote: >>> idList only has about 129 id numbers in it. >> That is quite a few times to be searching each line of the file. Try >> using a regular expression search instead, like this: >> >> import re >> regex = re.compile('|'.join(idList))

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

2007-06-26 Thread Robert Hicks
Kent Johnson wrote: > Robert Hicks wrote: >> idList only has about 129 id numbers in it. > > That is quite a few times to be searching each line of the file. Try > using a regular expression search instead, like this: > > import re > regex = re.compile('|'.join(idList)) > for line in f2: >if

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

2007-06-26 Thread Jason Massey
Also since you're writing your found results to a file there's no need to print the results to the screen. That should shave off some time, especially if you have a lot of hits. On 6/26/07, Kent Johnson <[EMAIL PROTECTED]> wrote: Robert Hicks wrote: > idList only has about 129 id numbers in it

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

2007-06-26 Thread Dave Kuhlman
On Tue, Jun 26, 2007 at 10:04:07AM -0400, Kent Johnson wrote: > Robert Hicks 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()) > >

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

2007-06-26 Thread Kent Johnson
Robert Hicks wrote: > idList only has about 129 id numbers in it. That is quite a few times to be searching each line of the file. Try using a regular expression search instead, like this: import re regex = re.compile('|'.join(idList)) for line in f2: if regex.search(line): # process a h

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

2007-06-26 Thread Robert Hicks
Kent Johnson wrote: > Robert Hicks 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) >> >> >> I have an list,

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

2007-06-26 Thread Kent Johnson
Robert Hicks 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) > > > I have an list, idList[], that contains a lis

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

2007-06-26 Thread Robert Hicks
Kent Johnson wrote: > Robert Hicks wrote: >> I have a script at work where I have a list of id numbers and I am doing a: >> >> for line in ehFile: > > That is fine > >> for id in line: > > I don't know what this is for - line is a string, iterating it will give > you every character is the

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

2007-06-25 Thread Kent Johnson
Robert Hicks wrote: > I have a script at work where I have a list of id numbers and I am doing a: > > for line in ehFile: That is fine > for id in line: I don't know what this is for - line is a string, iterating it will give you every character is the line. > > I am then going thr

[Tutor] Fastest way to iterate through a file

2007-06-25 Thread Robert Hicks
I have a script at work where I have a list of id numbers and I am doing a: for line in ehFile: for id in line: I am then going through that file and finding the line the id is on and printing the next line out. It takes a few seconds to see the output to the screen (the Perl versi