More on INCREF()?

Courageous jkraska1 at
Thu May 25 04:38:38 CEST 2000

Okay, so I'm building a Deque implementation for python (uh, yeah,
just for fun, 'sides I don't believe you guys when you say Python
lists are just as fast as linked lists, so I have to learn the
hard way, hahahaah), anyway....

I understand that if someone hands me a PyObject, I have to
INCREF() it. I also understand that if I remove it from one
of my nodes and hand it off, I DECREF() it.

I'm a bit nebulous, however, on what to do if someone "peeks"
at a node in my list. Say, for example, someone has an iterator
to my Deque and they "get" the PyObject associated with the
current iterator position.

It's my guess that Python assignment per se is handling the
INCREF(), and that I should do nothing. Ergo, the only time
I would be conducting INCREF/DECREF is when I store/unstore
PyObjects in my Deque.

Is this correct?


More information about the Python-list mailing list