APrioriInvestments / typed_python

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

Check that HeldClass and Dict/ConstDict semantics make sense. #423

Open braxtonmckee opened 1 year ago

braxtonmckee commented 1 year ago

For instance, does it make sense for a ConstDict(T, H) to return a refto its values if the dict is supposed to be const? Are the compiler and interpreter treatments for Dict and ConstDict the same? Does dict.pop of a held class return a copy of the instance in both interpreter and compiler?

Also, there's a nasty bug that user code could have: d is an instance of Dict(int, H) where H is some held class, then f(d.setdefault(0), d.setdefault(1)) could segfault, because the temporary reference returned by the first setdefault could be invalidated by the second setdefault. How should we handle this?

Similarly, we need to make sure that Dict and Set don't expose their key internals in a way that could modify them and invalidate the internals of the data structure.