[Types-sig] A type checking system in Python
Thu, 22 Mar 2001 17:10:21 +0100
Huaiyu Zhu wrote:
> > > - classes embody implementations
> > > - Types embody requirements
For the record, I agree with this. It feels natural to me..
as you can see if you have followed my discussions with Marcin.
I had a look at your code and it looks pretty cool. Simple enough yet
seems general and useful. Could be optimized of course, for example
using dicts instead of lists when looking up objects etc.
You use equality for object comparison. Maybe it should be pointer
equality (is) instead, or looking up on id(object).
Another problem may be that the Types hold references to objects so
they will not be garbage collected. Weak references could help, I
suppose. But then it wouldn't work with older Pythons.
Another thought was maybe one wants to be able to get at the types an
object implements. This seems possible if all the types were
registered in some global data-structure. Then it could be implemented
more or less efficiently.
The problem is we might not want central registries. Thread-safeness
could be a problem I suppose. But it can be solved, and maybe a
central register of types would give us advantages that would justify
some conceptual or implementational problems.