Re: PROPOSAL: A Generic Python Object Interface for Python C Modules

Guido.van.Rossum@cwi.nl
Thu, 02 Mar 1995 15:40:47 +0100

> My proposal is based on the current Python type system which expects
> most operator overloading to be done for things that behave generally
> like numbers. My proposal is also based on the underlying mechanism
> Python uses to manage this information. Perhaps this exposes too much
> of the underlying Python implementation.
>
> I personally would be perfectly happy to make these part of the Object
> protocol, or to make them part of an Operator protocol. If we do
> this, however, I would tend to want remove PySequence_Concat and
> PySequence_Repeat, treating them as special cases of PyOperator_Add
> and PyOperator_Multiple. This is really more consistent with the
> interpreter.
>
> Guido, What are your thoughts?

Hmm... Removing PySequence_Repeat would mean that I'd have to convert
my C integer repeat count to a Python object before I could use it.
There's no such problem with removing Concat, but I have a feeling
that C code that manipulates sequences would prefer to use
sequence-specific operations a lot. There's also the difference that
using Add or Multiply implies using coercions if they exist. Plus the
fact that for object types with multiple faces (e.g. vectors) it may
be necessary to disambiguate the operators. And... Perhaps the Add
operator is actually defined in terms of the Concat operation!
So I'd say leave them in.

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>