<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Arial;
        color:windowtext;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'>Hello there.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'>I am trying to insert a hook into python enabling a callback
for all just-created objects. The intention is to debug and find memory leaks,
e.g. by having the hook function insert the object into a WeakKeyDictionary.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'>I have already added a method to “object” to set
such a hook, and “object_new” now calls it upon completion, but
this is far from covering all places. Initially, I thought object_init were
the place, but almost no classes call object.__init__ from their __init__
method. Then there is the separate case of old-style classes.<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'>Any suggestions on how to do a global object creation hook
in python?<o:p></o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=IS style='font-size:10.0pt;
font-family:Arial'>Kristján<o:p></o:p></span></font></p>
</div>
</body>
</html>