[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: __eq operator behavior
- From: Daurnimator <quae@...>
- Date: Wed, 30 Mar 2011 20:33:21 +1100
On 30 March 2011 19:28, Drake Wilson <email@example.com> wrote:
> Quoth Dirk Laurie <firstname.lastname@example.org>, on 2011-03-30 10:16:16 +0200:
>> There is an efficiency argument as well. If two matrices differ
>> in the first element, one can immediately exit __ne, whereas you
>> would need to check the whole lot to evaluate __eq.
> Really? Why?
> ---> Drake Wilson
u==v would have to iterate over every value to check equality.
not u==v still iterates over the whole object
whereas u~=v can bail on the first index (1~=2)
In general, I'm not too sure about the merit of a __ne metamethod;
'a~=b' possibly returning a different result to 'not a==b'