trouble with the C API

Stefan Seefeld seefelds at MAGELLAN.UMontreal.CA
Tue Aug 22 09:19:41 EDT 2000


Thomas Wouters wrote:
> 
> On Mon, Aug 21, 2000 at 07:21:02PM +0000, Stefan Seefeld wrote:
> 
> > doesn't each object have two types, one static type, determined by the
> > type object it refers to and one dynamic type, given through the presence
> > (at a given point in time !) of a particular method or attribute ?
> > Why this ambiguity ?
> 
> You're confusing the C extention types with Python objects. The C PyObject*
> system is flexible, but not as flexible as Python classes. (Well, you can
> make them that flexible, but not easily so. And you pay a heavy price in
> performance, too.)

Sorry, I didn't make myself quite clear. I think I understand the problem
better now. The confusion I have comes from the mix of static and dynamic
types. Static in the sense that each object carries a type object reference
which determines part of its behavior and dynamic in the sense that the type
is infered by the existence of specific methods, as you call it here 'which
implement a particular protocol' such as a 'mapping type' etc.

If I understand correctly, the situation is the following:
You have static typing mainly for builtin types such as numbers, lists,
dictionaries etc. and a simple 'object' for user defined types. Then, for
user defined types, you have a totally unrelated type system based on the
above mentioned protocols which are implemented (sequence, mapping, callable
etc.). The latter type is infered at run time, i.e. by the interpreter while
it tries to resolve a method call on a given object.
For C++ programmers: this compares to generic programming, i.e. templates, with
the only difference that the types are infered/matched at compile time.

Does this make more sense ?

Regards,	Stefan

_______________________________________________________              
              
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds at magellan.umontreal.ca

_______________________________________________________

      ...ich hab' noch einen Koffer in Berlin...




More information about the Python-list mailing list