APrioriInvestments / typed_python

An llvm-based framework for generating and calling into high-performance native code from Python.
Apache License 2.0
198 stars 8 forks source link

Implement __copy_constructor__, __move__, and __assign__ for HeldClass #409

Open braxtonmckee opened 1 year ago

braxtonmckee commented 1 year ago

We want to be able to fully mimic C++ semantics for HeldClasses (since that's what they basically are). To do that we need to be able to model copy construction and instance movement.

Currently, our implementation assumes that all TP instances are trivially moveable (you can just copy the memory from one place to another). So to do this we will need to:

  1. mark all TP types that do not have trivial copy constructors or trivial move operators
  2. make sure we call those operators in the interpreter layer everywhere instead of just moving memory around at will
  3. ensure that we have a valid model for exceptions that get thrown during these calls
  4. implement them in the compiler
  5. optionally - make allow a pathway to let compiled versions of these functions get invoked by the interpreter if they're available

Once this is done, we should be able to implement any new data type directly in a HeldClass