Uniqueness of Data Type Instances
This MR refactors the type system to avoid multiple creation of data type instances by caching them. This improves the performance of comparing types, avoids unnecessary copies, and increases general efficiency of data type handling.
- Introduce the metaclass
PsTypeMeta
which keeps track of all existing instances of subclasses ofPsType
, and alters class instantiation to return existing instances instead of creating new ones - Refactor
__eq__
and__hash__
, which are now implemented inPsType
and use an__args__
method implemented by each instantiable subclass - Fix
constify
/deconstify
to no longer copy their arguments, but memoize their return values - Refactor and extend documentation of the type system to reflect the changes
Some minor additions come along:
- Move
create_type
fromtypes.quick
totypes.parsing
- Rename
types.basic_types
totypes.types
- Move
PsType
,constify
anddeconstify
totypes.meta
- Add an inheritance diagram to the type system documentation
Edited by Frederik Hennig