[Python-ideas] Support parsing stream with `re`

2015 at jmunch.dk 2015 at jmunch.dk
Sun Oct 7 12:45:28 EDT 2018

On 18-10-07 16.15, Ram Rachum wrote:
 > I tested it now and indeed bytes patterns work on memoryview objects.
 > But how do I use this to scan for patterns through a stream without
 > loading it to memory?

An mmap object is one of the things you can make a memoryview of,
although looking again, it seems you don't even need to, you can
just re.search the mmap object directly.

re.search'ing the mmap object means the operating system takes care of
the streaming for you, reading in parts of the file only as necessary.

regards, Anders

More information about the Python-ideas mailing list