[RFC] bzr.jrydberg.versionedfile
Johan Rydberg
jrydberg at gnu.org
Wed Dec 21 16:15:06 GMT 2005
Aaron Bentley <aaron.bentley at utoronto.ca> writes:
> Johan Rydberg wrote:
>> I disagree. I think get_text should be the primary operation, and
>> that it should return a list of lines. If you want it as a string,
>> we'll provide a convenience method for you.
>
> How about an iterable of lines, rather than a list per se? Maybe it's
> moot, given that we have to load the whole thing in memory while parsing
> the knit, but I can imagine cases in which we'd only want part of the
> file in memory at a time.
What cases is that?
If it is to return an iterable of lines, the implementation of
get_text will probably look something like this:
get_text(...):
...
for origin, line in foo:
yield line
So if you just want part of the lines in memory after the call to
get_text, it is probably better to do; get_text(...)[x:x+N].
But you are a better python programmer than me, so there might be
other advantages to return an iterator that I do not know.
~j
More information about the bazaar
mailing list