Python oddity

Martin Langhoff martin.langhoff at
Fri Aug 14 14:02:27 EDT 2009

Seems one of my roles in life is to find all the oddities in Python.
Hints from truly experienced Pythonistas welcome.

I am finding that after I do
  buf =
  match =

the next will always be to _at least_ the end of the match.
I can no longer or -- the call succeeds
but the next read() _always_ starts at the end of the last match. But!
We never seek to that particular point.

Is this expected? Known? Normal when reading the docs under the
influence of powerful drugs?

Sample script is attached for the truly curious - try it on a large
CJSON file, providing a separate file with dict keys to search for.
Once you get past the first 'page', and the code has to re-seek after
it found the match, you'll see the problem.

I suspect it's related to Python possibly having the file mmap()ed
behind the scenes, without telling me.

(What I am writing is actually a grep over very large files for cases
where python's mmap is not available. Say for instance our wonky


 martin.langhoff at
 martin at -- School Server Architect
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-python
Size: 3157 bytes
Desc: not available
URL: <>

More information about the Devel mailing list