Ville M. Vainio wrote:
Ricardo Aráoz <[EMAIL PROTECTED]> writes:
The easy/simple (too easy/simple?) way I see out of it is to read THE
WHOLE file into memory and don't worry. But what if the file is too
The easiest and simplest approach is often the best with
Python.
Keep forgetting that!
Ricardo Aráoz <[EMAIL PROTECTED]> writes:
> The easy/simple (too easy/simple?) way I see out of it is to read THE
> WHOLE file into memory and don't worry. But what if the file is too
The easiest and simplest approach is often the best with
Python. Reading in the whole file is rarely too heavy, a
On Tue, 13 May 2008 00:03:08 +1000, Ricardo Aráoz <[EMAIL PROTECTED]>
wrote:
Ville Vainio wrote:
On May 8, 8:11 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
All these examples assume your regular expression will not span
multiple
lines, but this can easily be the case. How would you proce
Ville Vainio wrote:
On May 8, 8:11 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
All these examples assume your regular expression will not span multiple
lines, but this can easily be the case. How would you process the file
with regular expressions that span multiple lines?
re.findall/ findit
On May 8, 8:11 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
> All these examples assume your regular expression will not span multiple
> lines, but this can easily be the case. How would you process the file
> with regular expressions that span multiple lines?
re.findall/ finditer, as I said earl
Anton Slesarev wrote:
I try to save my time not cpu cycles)
I've got file which I really need to parse:
-rw-rw-r-- 1 xxx xxx 3381564736 May 7 09:29 bigfile
That's my results:
$ time grep "python" bigfile | wc -l
2470
real0m4.744s
user0m2.441s
sys 0m2.307s
And python scrip
Alan Isaac wrote:
Anton Slesarev wrote:
I've read great paper about generators:
http://www.dabeaz.com/generators/index.html Author say that it's easy
to write analog of common linux tools such as awk,grep etc. He say
that performance could be even better. But I have some problem with
writing
Anton Slesarev wrote:
I've read great paper about generators:
http://www.dabeaz.com/generators/index.html
Author say that it's easy to write analog of common linux tools such
as awk,grep etc. He say that performance could be even better.
But I have some problem with writing performance grep an
On May 7, 7:22 pm, Pop User <[EMAIL PROTECTED]> wrote:
> Anton Slesarev wrote:
>
> > But I have some problem with writing performance grep analog.
>
> I don't think you can ever catch grep. Searching is its only purpose in
> life and its very good at it. You may be able to come closer, this
> thr
Anton Slesarev wrote:
But I have some problem with writing performance grep analog.
I don't think you can ever catch grep. Searching is its only purpose in
life and its very good at it. You may be able to come closer, this
thread relates.
http://groups.google.com/group/comp.lang.python/
On May 6, 10:42 pm, Anton Slesarev <[EMAIL PROTECTED]> wrote:
> flines = (line for line in f if pat.search(line))
What about re.findall() / re.finditer() for the whole file contents?
--
http://mail.python.org/mailman/listinfo/python-list
I try to save my time not cpu cycles)
I've got file which I really need to parse:
-rw-rw-r-- 1 xxx xxx 3381564736 May 7 09:29 bigfile
That's my results:
$ time grep "python" bigfile | wc -l
2470
real0m4.744s
user0m2.441s
sys 0m2.307s
And python scripts:
import sys
if len(
2008/5/6, Anton Slesarev <[EMAIL PROTECTED]>:
> But I have some problem with writing performance grep analog.
[...]
> Python code 3-4 times slower on windows. And as I remember on linux
> the same situation...
>
> Buffering in open even increase time.
>
> Is it possible to increase file readin
Anton Slesarev <[EMAIL PROTECTED]> writes:
> f = open("bigfile",'r')
>
> flines = (line for line in f if pat.search(line))
> c=0
> for x in flines:
> c+=1
> print c
It would be simpler (and probably faster) not to use a generator expression:
search = re.compile('sometext').search
c = 0
for
On Tue, May 6, 2008 at 1:42 PM, Anton Slesarev <[EMAIL PROTECTED]> wrote:
> Is it possible to increase file reading performance?
Dunno about that, but this part:
> flines = (line for line in f if pat.search(line))
> c=0
> for x in flines:
> c+=1
> print c
could be rewritten as just:
pr
15 matches
Mail list logo