branch-formats review

Martin Pool mbp at sourcefrog.net
Wed Feb 1 13:15:26 GMT 2006


Happy to say this is now landed in bzr.dev.

On  1 Feb 2006, Robert Collins <robertc at robertcollins.net> wrote:
> On Wed, 2006-02-01 at 00:33 +1100, Martin Pool wrote:
> 
> > > === modified file 'bzrlib/branch.py'
> > > --- bzrlib/branch.py	
> > > +++ bzrlib/branch.py	
> > > @@ -81,24 +90,38 @@
> > >      base
> > >          Base directory/url of the branch.
> > >      """
> > > +    # this is really an instance variable - FIXME move it there
> > > +    # - RBC 20060112
> > >      base = None
> > 
> > Yes, it is.  It's initialized here to give the default value, because of
> > the Python behaviour that class variables are seen underlying instance
> > variables.  I don't particularly *like* this behaviour but it did seem
> > to be well established. (?)  Maybe we shouldn't do this?
> 
> Its 'standard' python behaviour, but its a barrier to effective
> programming for non pythonistas. Unless theres a specific reason to use
> it (such as a large object, millions on instances owning such objects, a
> default that is not None, or a absolutely performance critical loop that
> is somehow not critical enough to redo in C :).

I agree that it can be confusing -- particularly if it's not just None
but a mutable object that's then accidentally globally changed.  It was
there more to show the default than for performance.

-- 
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060202/b6a5f23a/attachment.pgp 


More information about the bazaar mailing list