Is it possible to have a mutable type that is not garbage collected?

Posted by user136109 on Programmers See other posts from Programmers or by user136109
Published on 2014-06-09T22:31:33Z Indexed on 2014/06/10 3:41 UTC
Read the original article Hit count: 205

Filed under:

I'm wondering if such a thing can exist. Can there be an object that is mutable but not flagged as garbage collected ( specifically, tp_flags & Py_TPFLAGS_HAVE_GC )

I have a C++ struct-like object that I'm writing and I'd like to know if all of its members are immutable. I'm thinking of checking for the Py_TPFLAGS_HAVE_GC flag to determine this. If all members are immutable I want to speed up the deepcopy by doing a faster shallow copy, since I know members are immutable then it shouldn't have to go through an expensive deep copy.

Is this logically sound, or is there some mythical type that will blow me out of the water here.

© Programmers or respective owner

Related posts about python