Usefulness of subclassing builtin number types

Martin v. Löwis martin at v.loewis.de
Sun Dec 15 12:43:07 EST 2002


> Questions:
> 1) should the behaviour be changed and the necessary additional
>    indirection introduced for builtin types?

There are a number of semantic questions, such as:

- what should the result type be if it conceptually is a different type 
  (e.g. for __mul__, if the other argument is a float)? For that matter,
  what is the result type in StickyInt? (answer: raises TypeError)
- what should the result type be if there is a mix in the inheritance
  hierarchy (e.g. MyInt1(100)+MyInt2(200))?

There would need to be a careful specification, based on argument types
and operator, what the result type is.

Regards,
Martin




More information about the Python-list mailing list