[RFC] allow fulltext to be more dynamic

Dmitry Vasiliev lists at hlabs.spb.ru
Mon Nov 27 13:16:06 GMT 2006


John Arbash Meinel wrote:
> Dmitry Vasiliev wrote:
>> John Arbash Meinel wrote:
>>> +        self._max_delta_chain = 200
>>> +
>> Isn't it better to always define such a constants at the class level?
[skip]
> At least that is what I've understood from Martin and Robert. They don't
> really like having class level definitions which can be overridden per
> object and accessed as 'self._max_delta_chain'.

Hmm, have a default value at class level (which shared by all the objects) and 
override it per objects is a known pattern in Python world.

>> I'd prefer to localize often used variables inside loops (self._index in
>> this case).
> 
> I would only do it if it is a performance critical area. And I'm not
> sure if this is or not.
> 
> Otherwise the mental overhead of 'is is this index the other index that
> I'm thinking of....' starts to become too much.

Agreed, but BTW so many references to self._index raise another one question: 
shouldn't "check_should_delta" be a method of the index object?

> Seems okay. And actually with Henri's suggestion, rewriting it to be:
> 
> for count in xrange(self._max_chain_length):
>   ...
> else:
>   return False #Couldn't find a full text, so we must create a new one
> 
> # Create a delta if it will still be smaller than a fulltext
> return fulltext_size > delta_size

I like it more.

-- 
Dmitry Vasiliev (dima at hlabs.spb.ru)
     http://hlabs.spb.ru




More information about the bazaar mailing list