ext 0.1.0 - Copyright 2010 Urbán Dániel <urban.dani@gmail.com>

Monkey patching support for built-in types in CPython (3.x)

This python module makes it possible to add new attributes to built-in types, enabling the user to modify types implemented in C, which is not possible from Python code.

The code doing the monkey patching is in ext/_ext.c. It basically adds a new attribute to a built-in type's __dict__, and then calls PyType_Modified on the type. This way it is possible to add new methods (implemented in Python or C) or other class attributes to built-in types (like list). The module is experimental. I'm not sure which problems can result from modifying the dict of a built-in type. The module doesn't allow replacing an existing attribute of a type, so it is harder to render unusable the built-in types. The monkey patching also works on types implemented in Python (it just calls setattr after checking if there is already an attribute with the given name).