Hi Maarten,

On 29 Okt., 12:59, Maarten Derickx <m.derickx.stud...@gmail.com>
wrote:
> I would certainly let the methods also exist in the future since regular
> users might also be interested in the info.

Agreed. My current proposal is to keep the methods and have underscore
lazy attributes.

> And although Simon showed that calling a property is
> slightly slower (3.5%) then a method, it does have the advantage that it
> saves you typing two useless parenthesis.

The point I wanted to make is: It doesn't matter how much slower a
property is than a method, since calling a method is already too slow.

If we care for speed, then neither a usual method nor a usual property
are options. IMHO, we should either
 (1) get finally someone to review #11115, so that calling a cached
method is only 120ns slower than requesting an attribute,
or
 (2) use underscore lazy attributes internally, but keep the methods
around, for documentation.

(1) means: We have fairly good speed and we have documentation.
(2) means: We have best speed and we have documentation, but the
method carrying the documentation is not used internally.

> And even more important it allows
> for tab completion in ipython as shown below.

That's exactly the same for lazy attributes.

> I would find this tabcompletion very usefull for certain properties since I
> have often done something like:
> tmp = Object.method_wich_could_be_an_attribute()
> just to be able to have tab completion on tmp to see if it allowed me to do
> with it what I want.

When you do tmp = b.some_property, followed by tmp?, then you see the
documentation of the return value of b.some_property.

Is that really what you want to see? Then you are arguing *against*
the use of properties, because b.some_property? will show you the
documentation of the property itself (not of its return value).

If you do b.some_lazy_attribute?, then you will see the documentation
of the return value (which I don't like).

If you do b.some_cached_method? then you will see the documentation of
the function that returns the value, and of course
b.some_cached_method()? won't work.

Best regards,
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to