[RFC] bzr.jrydberg.versionedfile

John Arbash Meinel john at arbash-meinel.com
Wed Dec 21 16:19:41 GMT 2005


Johan Rydberg wrote:
> 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
> 

Well if we make the contract such that it returns an iterator, in the
future you could change the implementation so that it wouldn't have to
read the entire file before it returns text.
I don't know if this would lead to any improvement. Or if it just means
that most of the callers will start using:

text = list(get_text())
Which makes things worse instead of better.

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051221/aceb9326/attachment.pgp 


More information about the bazaar mailing list