Overriding operator delete in a Python extension

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Wilkinson

    Overriding operator delete in a Python extension

    Hi,

    This is probably more of a gcc question than a python one, but hopefully
    someone out their will know that answer.

    I've written a C++ Python extension, and as part of it I override the
    operator new and operator delete functions to provide memory leak tracking
    from within the extension.

    When I use the code as part of a complete C++ program everything works
    perfectly, however when I compile it with my Python interface code the
    operator delete function is not called - the operator new function is
    called as normal however. I assume this is because the function is not
    linked correctly, but I'm at a loss for how to make the linker resolve the
    references in the .so file.

    Does anyone know a possible solution to my problem?
    Regards,
    Andrew Wilkinson

    --
    University is a fountain of knowledge, and students go there to drink.


  • Aahz

    #2
    Re: Overriding operator delete in a Python extension

    In article <bubnvd$7v1$1@p ump1.york.ac.uk >,
    Andrew Wilkinson <ajw140NO@SPAM. york.ac.uk> wrote:[color=blue]
    >
    >I've written a C++ Python extension, and as part of it I override the
    >operator new and operator delete functions to provide memory leak tracking
    >from within the extension.
    >
    >When I use the code as part of a complete C++ program everything works
    >perfectly, however when I compile it with my Python interface code the
    >operator delete function is not called - the operator new function is
    >called as normal however. I assume this is because the function is not
    >linked correctly, but I'm at a loss for how to make the linker resolve the
    >references in the .so file.
    >
    >Does anyone know a possible solution to my problem?[/color]

    Use Boost.Python.
    --
    Aahz (aahz@pythoncra ft.com) <*> http://www.pythoncraft.com/

    A: No.
    Q: Is top-posting okay?

    Comment

    Working...