[pypy-dev] PyPy newbie question: How to play with types

Noam Raphael noamraph at gmail.com
Sun Nov 13 00:44:32 CET 2005


I want to use PyPy as a way of trying a change I will propose to
Python. It includes a bit of messing with types. For example, I want
to make a new type called frozendict, and another new type, basedict.

frozendict and dict will be subclasses of basedict. basedict will not
be instantiable, but will implement all the dict methods that do not
change the dict. frozendict will add a single operation to basedict -
it will be hashable. dict will be the same as the dict today, but
since many operations will be inherited from basedict, it will be

I also want to add a new built-in, frozen(x), that will simply call

I have looked into the directories. I have found
pypy/objspace/dict{object,type}.py. My questions are:

1. How do I make new built-in types, play with their inheritence, make
them uninstantiable? Should I register it somewhere?
2. Where do I add a new built-in like frozen()? How should I make it
callable from interpreter-level code?

Thanks a lot,

More information about the Pypy-dev mailing list