On 2/27/07, Travis E. Oliphant <[EMAIL PROTECTED]> wrote:
> Maybe I'm not understanding you correctly.  Perhaps what you are saying
> is that we should have all memory allocation go through a light-weight
> memory-object.  Then, you would get this object + an offset when you
> wanted a pointer into memory.
>
> This way, the memory would never be deallocated until nothing was
> referencing it.  I think this approach would work.   However, you could
> still have the case, where an object reallocated memory while another
> object which thought it had a view of that object ended up with a
> "out-dated" view.   You just wouldn't segfault in that case.
>
> You could check the reference count on the memory object, before
> reallocating, I suppose.

You have understood me correctly.

(though I see that Greg Ewing has raised a good objection so its a moot point)

> But I've heard that the reference counts on
> Python objects can be larger than 1 in some cases (even though there
> isn't really anything "viewing" the memory).

Is that true?

I'm writing an extension module (for my own use and to scratch an
itch) that relies on the following notion:

    If a C module never exposes an object to the user, then the
object's reference counter is only incremented/decremented by the
module.

Does the garbage collector sometimes temporarily increment reference
counters in the course of its operation?  I looked through the code,
but didn't see anything to that effect (except with regard to weak
reference objects).  I can't see how anything other than the garbage
collector would even find such an object.

-- 
Daniel Stutzbach, Ph.D.             President, Stutzbach Enterprises LLC
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to