Skip to content
Snippets Groups Projects

Type System Refactor

Merged Frederik Hennig requested to merge fhennig/type-system-refactor into backend-rework

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 of PsType, and alters class instantiation to return existing instances instead of creating new ones
  • Refactor __eq__ and __hash__, which are now implemented in PsType 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 from types.quick to types.parsing
  • Rename types.basic_types to types.types
  • Move PsType, constify and deconstify to types.meta
  • Add an inheritance diagram to the type system documentation

Merge request reports

Pipeline #65310 passed

Pipeline passed for 39846f25 on fhennig/type-system-refactor

Checking approval status

Merged by Markus HolzerMarkus Holzer 10 months ago (Apr 23, 2024 6:44am UTC)

Merge details

  • Changes merged into with 3ee5d9b6.
  • Deleted the source branch.

Pipeline #65346 passed

Pipeline passed for 3ee5d9b6 on backend-rework

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply