Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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

Project Description

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).

Release History

Release History

This version
History Node

0.1.0

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting