Fredrik Johansson <[EMAIL PROTECTED]> added the comment: > One other note: in Fredrik's patch there's commented out code for a > numbits *property* (rather than a method). Is there any good reason to > make this a property?
Aesthetically, I think numbits as a function would make more sense. (Maybe if the hypothetical imath module comes along...) > Since numbits() cost is O(n) with n: number of digits. I prefer a > method than a property because, IMHO, reading a property should be > O(1) (*read* an attribute is different than *compute* a value). Unless I missed something, numbits() is O(1). Only the topmost word in a number needs to be examined. > reading a property should be O(1) (*read* an attribute is different > than *compute* a value). O(1) is necessary but not sufficient. My sense is that an attribute should access an existing "part" of an object while an operation that involves creating a "new" object should be a method. Compare complex.real/.imag and complex.conjugate(). _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3439> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com