@phenaff The solution to all this is to use the boost shared_ptr. We can then properly share a given instance and make sure it only gets deallocated when the last existing pointer is deleted. Most of the Python wrappers in PyQL are using shared_ptr in place of regular pointers. 

In the Period class the internal _thisptr attribute is a shared_ptr[QlPeriod]*. Using this is perfectly predictable in terms of behaviour in the dealloc. The reference used by the shared pointer will only be deallocated when the ref count hits 0.