A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-September/017638.html below:

[Python-Dev] Re: __op__ and __rop__ ([Python-checkins] CVS: python/dist/src PLAN.txt,1.10,1.11)

[Python-Dev] Re: __op__ and __rop__ ([Python-checkins] CVS: python/dist/src PLAN.txt,1.10,1.11)M.-A. Lemburg mal@lemburg.com
Fri, 28 Sep 2001 22:43:07 +0200
Guido van Rossum wrote:
> 
> + Treat all binary operators the same way as I just did for rich
> + comparison: in a <op> b, if isinstance(b, type(a)), try b.__rop__(a)
> + before trying a.__op__(b).

Some comments (could be that I'm misunderstanding your note...):

- doesn't this cause an incompatibility to classic instances
  (__rop__ is fallback to __op__ not the other way around) ?

- it seems a huge performance loss to first check for __rop__
  (in my experience, __rop__ is only rarely implemented)

The classic scheme for this is documented in abstract.c:

  Calling scheme used for binary operations:

  v	w	Action
  -------------------------------------------------------------------
  new	new	v.op(v,w), w.op(v,w)
  new	old	v.op(v,w), coerce(v,w), v.op(v,w)
  old	new	w.op(v,w), coerce(v,w), v.op(v,w)
  old	old	coerce(v,w), v.op(v,w)

  Legend:
  -------
  * new == new style number
  * old == old style number
  * Action indicates the order in which operations are tried until either
    a valid result is produced or an error occurs.

Most (if not all) Python builtin numeric types are new-style
numbers. How would your plan fit into this picture ?

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4