Commit a781cf43 authored by Denis Bilenko's avatar Denis Bilenko

core.buffer: implement iterator protocol

parent 362ce7ef
......@@ -45,10 +45,14 @@ cdef class buffer:
def detach(self):
self.__obj = NULL
# cython does not implement generators
#def __iter__(self):
# while len(self):
# yield self.readline()
def __iter__(self):
return self
def __next__(self):
line = self.readline()
if not line:
raise StopIteration
return line
def read(self, long size=-1):
"""Drain the first *size* bytes from the buffer (or what's left if there are less than *size* bytes).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment