A set of small classes to represent Python runtime objects - modules, classes, functions, constants, and abstract instances - in a structured and consistent way.
Project description
python-runtime-entity-wrappers
A set of small classes to represent Python runtime objects - modules, classes, functions, constants, and abstract instances - in a structured and consistent way. This is especially useful for symbolic interpreters, type systems, or metaprogramming tasks where you need clear semantics of identity and equality for runtime terms.
Classes
| Wrapper | What it Represents | Comparison Semantics |
|---|---|---|
| Module | Python module objects | By module instance |
| Class | Python class/type objects | By class instance |
| Function | Python function or built-in function | By function instance |
| Constant | Immutable primitive values | By value |
| AbstractInstance | Abstract instance of a class (not a real object) | By identity (each AbstractInstance is unique) |
Usage
from python_runtime_entity_wrappers import Module, Class, Function, Constant, AbstractInstance
import math
# Module: refers to the 'math' module object
m1 = Module(math)
m2 = Module(math)
assert m1 == m2
# Class: refers to a Python class
class MyClass: pass
c1 = Class(MyClass)
c2 = Class(MyClass)
assert c1 == c2
# Function: refers to a Python function
def foo(): return 42
f1 = Function(foo)
f2 = Function(foo)
assert f1 == f2
# Constant: refers to a literal/primitive value
k1 = Constant(123)
k2 = Constant(123)
assert k1 == k2
# AbstractInstance: refers to an *abstract* instance of a class (not a real Python object)
i1 = AbstractInstance(MyClass)
i2 = AbstractInstance(MyClass)
assert i1 != i2 # Each AbstractInstance(...) is unique (identity equality)
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_runtime_entity_wrappers-0.1.0a0.tar.gz.
File metadata
- Download URL: python_runtime_entity_wrappers-0.1.0a0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4697579673c3210cbdb89191df8f28eab52d839e675472b83642d776e171467c
|
|
| MD5 |
84cfb00446bab52259765b2acbcb903d
|
|
| BLAKE2b-256 |
7c06a71a4df9b706ef2e324bc1e7887e2773bb2395924e5dd4a40b008b0d4823
|
File details
Details for the file python_runtime_entity_wrappers-0.1.0a0-py2.py3-none-any.whl.
File metadata
- Download URL: python_runtime_entity_wrappers-0.1.0a0-py2.py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0692b18cd8741c91e3083271ad50ea33c0a09b1a67cb680cbb05df577def104c
|
|
| MD5 |
13e92436a47640a52cb236f17768ae07
|
|
| BLAKE2b-256 |
eeff1574eebe59efee0718e69c24cb65404b020ab355166cf79ab368b93ffa65
|