use singleton in simple enum `IntoPyObject`
This attempts solving #3059 by changing the generated IntoPyObject implementation for simple enums.
This lazily stores the instances in a static array and creates them on first access.
This solves the issue for the cases where IntoPyObject is used, so for example the class attribute and function return types can now be compared by identity. This does not solve the issue that Py|Bound::new behave differently here. This is similar to #3747 as well. The solution for that is probably to remove the impl<T> From<T> for PyClassInitializer<T> blanket and instead emit customized code via #[pyclass]. That could be done as a follow up.
The solution for that is probably to remove the
impl<T> From<T> for PyClassInitializer<T>blanket and instead emit customized code via#[pyclass]. That could be done as a follow up.
👍 I think there's a bunch of improvement we could do the initializer API, also with how subclassing works etc.