(Please keep posting on this list) --- [EMAIL PROTECTED] escribió:
> Thanks, but this method still reads the whole line > into memory. I would like to find a way for it to > stop reading when it encounters a \t and then go to > the next. This would be much faster. You can't avoid reading the whole line - how can you detect the end-of-line, unless you use fixed-length records? > According to my tests, readlines with a regular > expression is actually faster than the index method > you mentioned. Here is the code testing a 25meg file > with thousands of lines, Hard to believe, altough that depends on a lot of factors. Is the posted code all your testing code? If so, it doesn't look right. Write two separate functions, without side effects each (in this case, that means using a local variable for kwords). Let's call them f1 and f2, inside kw.py. Use the timeit module to measure performance instead of time.time(). Execute both functions *separately* on two *separate* Python invocations, like this: python -m timeit -s "from kw import f1,f2" "f1()" python -m timeit -s "from kw import f1,f2" "f2()" and see what happens. -- Gabriel Genellina __________________________________________________ Preguntá. Respondé. Descubrí. Todo lo que querías saber, y lo que ni imaginabas, está en Yahoo! Respuestas (Beta). ¡Probalo ya! http://www.yahoo.com.ar/respuestas -- http://mail.python.org/mailman/listinfo/python-list