Basically +1 for Volker's suggestion. Vincent's suggestion on the
semantics of "copy" in constructors seem very dangerous: even if my
construction of MyNewObject works today, a seemingly unrelated change to
either the caller code or MyNewObject tomorrow could completely break
things in highly surprising ways. Don't share mutable objects in subtle
ways, when it's natural to think about mathematical objects in an
immutable way.

About the naming of the copying form versus in-place form, note that
matrices currently have e.g. echelon_form/echelonize and
hessenberg_form/hessenbergize. Standardisation would dictate echeloned
or echelon_formed?

Best,
Johan




Volker Braun writes:

> IMHO both foo(copy=True) and foo(inplace=False) are fugly and best avoided. 
> They are unintuitive and not discoverable. Basically they are patterns for 
> an API that you can only use by constantly looking up the documentation. 
>
> If possible, methods should act in-place since that is the most versatile 
> (you cannot un-copy, but you can easily make a copy before acting). So that 
> should always be the default. Of course if the object can be immutable then 
> you can't act in-place. Use past tense to name the copying form of the 
> method. 
>
> E.g. list.sort() vs. sorted(). 
>
> * The in-place operation is more useful and therefore the list method
> * The -ed implies copy.
>
> In constructors its best to make copies of mutable data and reference 
> immutable data. Just do the right thing, don't trick the user into 
> introducing subtle errors MyNewObject(data_list, copy=False) or 
> unnecessarily waste memory MyNewObject(data_tuple, copy=True).
>
>
>
> On Friday, August 21, 2015 at 2:08:45 PM UTC-4, vdelecroix wrote:
>>
>> Hello, 
>>
>> While looking at #18481, I realized that we have two argument names that 
>> have the same purpose: "copy" and "inplace" (one being the contrary of 
>> the other of course). As it is worth a convention, I am just asking for 
>> your preferences: 
>>   1. It does not matter 
>>   2. Functions should accept both, ie both my_function(copy=True) and 
>> my_function(inplace=True) should work 
>>   2. "inplace" is better 
>>   3. "copy" is better 
>>   4. we need another argument name 
>>   5. ? 
>>
>> Best, 
>> Vincent 
>>

-- 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to