use of properties

Martin Pool mbp at sourcefrog.net
Thu Jan 5 02:15:17 GMT 2006


On Thu, 2006-01-05 at 13:00 +1100, Robert Collins wrote:
> Hi, 
> 	We seem to have some varied uses of properties. I'd like to draw
> everyones attention to a recent PEP8 change, which is that properties
> should not be used for anything that has non trivial performance
> implications. (To me, this means anything that reads or writes from disk
> should never be a property).
> 
> The thing that got me dropping this mail to the list is 'branch.nick'
> which can potentially take many seconds on slow transports: a get and
> set method is entirely appropriate here.

I second that.  I don't think the presence of just get_x and set_x
implies that you should instead have a property x (as it might in other
languages).  I'm not sure precisely what the criteria should be, but I
would suggest being careful in adding them.  The one that I added,
tree.inventory, was possibly a mistake.

One reasonable justification may be that you want to avoid breaking
callers who expect a field, but to add more behaviour.  Obviously this
implies it should still have similar semantics and behaviour to a field.

-- 
Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060105/cc06bae3/attachment.pgp 


More information about the bazaar mailing list