__del__ warnings apply to tp_dealloc?

Discussion in 'Python' started by Jey Kottalam, Feb 3, 2004.

  1. Jey Kottalam

    Jey Kottalam Guest

    Hi,

    The Python 2.3 Language Reference cautions that __del__ is not guarnateed to
    be invoked at
    http://www.python.org/doc/current/ref/customization.html#l2h-175 . I am
    writing a Python extension in C and I was wondering if the same precautions
    apply to tp_dealloc, that is, is there a possibility that the tp_delloc for
    my type may not be invoked?

    Thanks in advance,
    Jey Kottalam
    Jey Kottalam, Feb 3, 2004
    #1
    1. Advertising

  2. Jey Kottalam

    Greg Chapman Guest

    On Mon, 2 Feb 2004 21:29:15 -0800, "Jey Kottalam" <>
    wrote:

    >Hi,
    >
    >The Python 2.3 Language Reference cautions that __del__ is not guarnateed to
    >be invoked at
    >http://www.python.org/doc/current/ref/customization.html#l2h-175 . I am
    >writing a Python extension in C and I was wondering if the same precautions
    >apply to tp_dealloc, that is, is there a possibility that the tp_delloc for
    >my type may not be invoked?
    >


    Yes, there is no guarantee that all tp_deallocs will be called when the
    interpreter exits. In CPython, the interpreter does try to clean up when it
    exits by clearing out all the modules, which will generally cause most objects
    to have their tp_dealloc called. However, if the object is in a refcount cycle,
    there is no guarantee that the cycle will get collected.

    Note also that, unlike a python __del__ method, a tp_dealloc method will not
    keep the garbage collector from collecting cycles.

    ---
    Greg Chapman
    Greg Chapman, Feb 3, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    1
    Views:
    949
    Marrow
    Jul 18, 2003
  2. Jane Austine
    Replies:
    2
    Views:
    338
    Steven Taschuk
    Jul 2, 2003
  3. Ted Sung
    Replies:
    1
    Views:
    299
    Sherm Pendley
    Aug 30, 2004
  4. Replies:
    1
    Views:
    87
    Paul Lalli
    Jan 6, 2005
  5. Alf P. Steinbach
    Replies:
    1
    Views:
    170
    Alf P. Steinbach
    Oct 15, 2013
Loading...

Share This Page