Is there any possibility to copy variable by reference no matter if its int or class instance?
My goal is to have two lists of the same objects and when one changes, change is visible in second.
In other words i need pointers:/
I simply want int, float and other standard types which are normally copied by value, force to copy by reference. This will make my code more consistent.
If there is no such possibility, class wrapper is the best solution.
(edited to show example of dereferencing to same memory location)
Luper Rouch’s approach is spot-on when dealing with lists of mixed-types. Just wrap the immutable types with containers.
If you really insist on C-style arrays where the elements are constrained to being a single type (array of ints, array of chars, etc), you could use the
ctypesmodule. It’ll give you access to c data types and pointers in addition to an FFI to use DLLs.Result: