Debian Codegraph @

docs/pydoc/pydispatch.saferef.html

raw symbols SCIP
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><title>Python: module pydispatch.saferef</title>
3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4 </head><body bgcolor="#f0f0f8">
5
6 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
7 <tr bgcolor="#7799ee">
8 <td valign=bottom>&nbsp;<br>
9 <font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="pydispatch.html"><font color="#ffffff">pydispatch</font></a>.saferef</strong></big></big></font></td
10 ><td align=right valign=bottom
11 ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/mcfletch/OpenGL-dev/pydispatcher/pydispatch/saferef.py">/home/mcfletch/OpenGL-dev/pydispatcher/pydispatch/saferef.py</a></font></td></tr></table>
12 <p><tt>Refactored&nbsp;"safe&nbsp;reference"&nbsp;from&nbsp;dispatcher.py</tt></p>
13 <p>
14 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
15 <tr bgcolor="#aa55cc">
16 <td colspan=3 valign=bottom>&nbsp;<br>
17 <font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
18
19 <tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
20 <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="sys.html">sys</a><br>
21 </td><td width="25%" valign=top><a href="traceback.html">traceback</a><br>
22 </td><td width="25%" valign=top><a href="weakref.html">weakref</a><br>
23 </td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
24 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
25 <tr bgcolor="#ee77aa">
26 <td colspan=3 valign=bottom>&nbsp;<br>
27 <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
28
29 <tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
30 <td width="100%"><dl>
31 <dt><font face="helvetica, arial"><a href="builtins.html#object">object</a>
32 </font></dt><dd>
33 <dl>
34 <dt><font face="helvetica, arial"><a href="pydispatch.saferef.html#BoundMethodWeakref">BoundMethodWeakref</a>
35 </font></dt></dl>
36 </dd>
37 </dl>
38 <p>
39 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
40 <tr bgcolor="#ffc8d8">
41 <td colspan=3 valign=bottom>&nbsp;<br>
42 <font color="#000000" face="helvetica, arial"><a name="BoundMethodWeakref">class <strong>BoundMethodWeakref</strong></a>(<a href="builtins.html#object">object</a>)</font></td></tr>
43
44 <tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
45 <td colspan=2><tt><a href="#BoundMethodWeakref">BoundMethodWeakref</a>(target,&nbsp;onDelete=None,&nbsp;*arguments,&nbsp;**named)<br>
46 &nbsp;<br>
47 'Safe'&nbsp;and&nbsp;reusable&nbsp;weak&nbsp;references&nbsp;to&nbsp;instance&nbsp;methods<br>
48 &nbsp;<br>
49 <a href="#BoundMethodWeakref">BoundMethodWeakref</a>&nbsp;objects&nbsp;provide&nbsp;a&nbsp;mechanism&nbsp;for<br>
50 referencing&nbsp;a&nbsp;bound&nbsp;method&nbsp;without&nbsp;requiring&nbsp;that&nbsp;the<br>
51 method&nbsp;<a href="builtins.html#object">object</a>&nbsp;itself&nbsp;(which&nbsp;is&nbsp;normally&nbsp;a&nbsp;transient<br>
52 <a href="builtins.html#object">object</a>)&nbsp;is&nbsp;kept&nbsp;alive.&nbsp;&nbsp;Instead,&nbsp;the&nbsp;<a href="#BoundMethodWeakref">BoundMethodWeakref</a><br>
53 <a href="builtins.html#object">object</a>&nbsp;keeps&nbsp;weak&nbsp;references&nbsp;to&nbsp;both&nbsp;the&nbsp;<a href="builtins.html#object">object</a>&nbsp;and&nbsp;the<br>
54 function&nbsp;which&nbsp;together&nbsp;define&nbsp;the&nbsp;instance&nbsp;method.<br>
55 &nbsp;<br>
56 Attributes:<br>
57 &nbsp;&nbsp;&nbsp;&nbsp;key&nbsp;--&nbsp;the&nbsp;identity&nbsp;key&nbsp;for&nbsp;the&nbsp;reference,&nbsp;calculated<br>
58 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;by&nbsp;the&nbsp;class's&nbsp;calculateKey&nbsp;method&nbsp;applied&nbsp;to&nbsp;the<br>
59 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target&nbsp;instance&nbsp;method<br>
60 &nbsp;&nbsp;&nbsp;&nbsp;deletionMethods&nbsp;--&nbsp;sequence&nbsp;of&nbsp;callable&nbsp;objects&nbsp;taking<br>
61 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;single&nbsp;argument,&nbsp;a&nbsp;reference&nbsp;to&nbsp;this&nbsp;<a href="builtins.html#object">object</a>&nbsp;which<br>
62 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;will&nbsp;be&nbsp;called&nbsp;when&nbsp;*either*&nbsp;the&nbsp;target&nbsp;<a href="builtins.html#object">object</a>&nbsp;or<br>
63 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target&nbsp;function&nbsp;is&nbsp;garbage&nbsp;collected&nbsp;(i.e.&nbsp;when<br>
64 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this&nbsp;<a href="builtins.html#object">object</a>&nbsp;becomes&nbsp;invalid).&nbsp;&nbsp;These&nbsp;are&nbsp;specified<br>
65 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;as&nbsp;the&nbsp;onDelete&nbsp;parameters&nbsp;of&nbsp;safeRef&nbsp;calls.<br>
66 &nbsp;&nbsp;&nbsp;&nbsp;weakSelf&nbsp;--&nbsp;weak&nbsp;reference&nbsp;to&nbsp;the&nbsp;target&nbsp;<a href="builtins.html#object">object</a><br>
67 &nbsp;&nbsp;&nbsp;&nbsp;weakFunc&nbsp;--&nbsp;weak&nbsp;reference&nbsp;to&nbsp;the&nbsp;target&nbsp;function<br>
68 &nbsp;<br>
69 Class&nbsp;Attributes:<br>
70 &nbsp;&nbsp;&nbsp;&nbsp;_allInstances&nbsp;--&nbsp;class&nbsp;attribute&nbsp;pointing&nbsp;to&nbsp;all&nbsp;live<br>
71 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#BoundMethodWeakref">BoundMethodWeakref</a>&nbsp;objects&nbsp;indexed&nbsp;by&nbsp;the&nbsp;class's<br>
72 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#BoundMethodWeakref-calculateKey">calculateKey</a>(target)&nbsp;method&nbsp;applied&nbsp;to&nbsp;the&nbsp;target<br>
73 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objects.&nbsp;&nbsp;This&nbsp;weak&nbsp;value&nbsp;dictionary&nbsp;is&nbsp;used&nbsp;to<br>
74 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;short-circuit&nbsp;creation&nbsp;so&nbsp;that&nbsp;multiple&nbsp;references<br>
75 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;the&nbsp;same&nbsp;(<a href="builtins.html#object">object</a>,&nbsp;function)&nbsp;pair&nbsp;produce&nbsp;the<br>
76 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;same&nbsp;<a href="#BoundMethodWeakref">BoundMethodWeakref</a>&nbsp;instance.<br>&nbsp;</tt></td></tr>
77 <tr><td>&nbsp;</td>
78 <td width="100%">Methods defined here:<br>
79 <dl><dt><a name="BoundMethodWeakref-__bool__"><strong>__bool__</strong></a> = <a href="#BoundMethodWeakref-__nonzero__">__nonzero__</a>(self)</dt></dl>
80
81 <dl><dt><a name="BoundMethodWeakref-__call__"><strong>__call__</strong></a>(self)</dt><dd><tt>Return&nbsp;a&nbsp;strong&nbsp;reference&nbsp;to&nbsp;the&nbsp;bound&nbsp;method<br>
82 &nbsp;<br>
83 If&nbsp;the&nbsp;target&nbsp;cannot&nbsp;be&nbsp;retrieved,&nbsp;then&nbsp;will<br>
84 return&nbsp;None,&nbsp;otherwise&nbsp;returns&nbsp;a&nbsp;bound&nbsp;instance<br>
85 method&nbsp;for&nbsp;our&nbsp;<a href="builtins.html#object">object</a>&nbsp;and&nbsp;function.<br>
86 &nbsp;<br>
87 Note:<br>
88 &nbsp;&nbsp;&nbsp;&nbsp;You&nbsp;may&nbsp;call&nbsp;this&nbsp;method&nbsp;any&nbsp;number&nbsp;of&nbsp;times,<br>
89 &nbsp;&nbsp;&nbsp;&nbsp;as&nbsp;it&nbsp;does&nbsp;not&nbsp;invalidate&nbsp;the&nbsp;reference.</tt></dd></dl>
90
91 <dl><dt><a name="BoundMethodWeakref-__cmp__"><strong>__cmp__</strong></a>(self, other)</dt><dd><tt>Compare&nbsp;with&nbsp;another&nbsp;reference</tt></dd></dl>
92
93 <dl><dt><a name="BoundMethodWeakref-__init__"><strong>__init__</strong></a>(self, target, onDelete=None)</dt><dd><tt>Return&nbsp;a&nbsp;weak-reference-like&nbsp;instance&nbsp;for&nbsp;a&nbsp;bound&nbsp;method<br>
94 &nbsp;<br>
95 target&nbsp;--&nbsp;the&nbsp;instance-method&nbsp;target&nbsp;for&nbsp;the&nbsp;weak<br>
96 &nbsp;&nbsp;&nbsp;&nbsp;reference,&nbsp;must&nbsp;have&nbsp;&lt;im_self&gt;&nbsp;and&nbsp;&lt;im_func&gt;&nbsp;attributes<br>
97 &nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;be&nbsp;reconstructable&nbsp;via:<br>
98 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;target.&lt;im_func&gt;.__get__(&nbsp;target.&lt;im_self&gt;&nbsp;)<br>
99 &nbsp;&nbsp;&nbsp;&nbsp;which&nbsp;is&nbsp;true&nbsp;of&nbsp;built-in&nbsp;instance&nbsp;methods.<br>
100 onDelete&nbsp;--&nbsp;optional&nbsp;callback&nbsp;which&nbsp;will&nbsp;be&nbsp;called<br>
101 &nbsp;&nbsp;&nbsp;&nbsp;when&nbsp;this&nbsp;weak&nbsp;reference&nbsp;ceases&nbsp;to&nbsp;be&nbsp;valid<br>
102 &nbsp;&nbsp;&nbsp;&nbsp;(i.e.&nbsp;either&nbsp;the&nbsp;<a href="builtins.html#object">object</a>&nbsp;or&nbsp;the&nbsp;function&nbsp;is&nbsp;garbage<br>
103 &nbsp;&nbsp;&nbsp;&nbsp;collected).&nbsp;&nbsp;Should&nbsp;take&nbsp;a&nbsp;single&nbsp;argument,<br>
104 &nbsp;&nbsp;&nbsp;&nbsp;which&nbsp;will&nbsp;be&nbsp;passed&nbsp;a&nbsp;pointer&nbsp;to&nbsp;this&nbsp;<a href="builtins.html#object">object</a>.</tt></dd></dl>
105
106 <dl><dt><a name="BoundMethodWeakref-__nonzero__"><strong>__nonzero__</strong></a>(self)</dt><dd><tt>Whether&nbsp;we&nbsp;are&nbsp;still&nbsp;a&nbsp;valid&nbsp;reference</tt></dd></dl>
107
108 <dl><dt><a name="BoundMethodWeakref-__repr__"><strong>__repr__</strong></a> = <a href="#BoundMethodWeakref-__str__">__str__</a>(self)</dt></dl>
109
110 <dl><dt><a name="BoundMethodWeakref-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>Give&nbsp;a&nbsp;friendly&nbsp;representation&nbsp;of&nbsp;the&nbsp;<a href="builtins.html#object">object</a></tt></dd></dl>
111
112 <hr>
113 Class methods defined here:<br>
114 <dl><dt><a name="BoundMethodWeakref-calculateKey"><strong>calculateKey</strong></a>(target)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">type</a></font></font></dt><dd><tt>Calculate&nbsp;the&nbsp;reference&nbsp;key&nbsp;for&nbsp;this&nbsp;reference<br>
115 &nbsp;<br>
116 Currently&nbsp;this&nbsp;is&nbsp;a&nbsp;two-tuple&nbsp;of&nbsp;the&nbsp;id()'s&nbsp;of&nbsp;the<br>
117 target&nbsp;<a href="builtins.html#object">object</a>&nbsp;and&nbsp;the&nbsp;target&nbsp;function&nbsp;respectively.</tt></dd></dl>
118
119 <hr>
120 Static methods defined here:<br>
121 <dl><dt><a name="BoundMethodWeakref-__new__"><strong>__new__</strong></a>(cls, target, onDelete=None, *arguments, **named)</dt><dd><tt>Create&nbsp;new&nbsp;instance&nbsp;or&nbsp;return&nbsp;current&nbsp;instance<br>
122 &nbsp;<br>
123 Basically&nbsp;this&nbsp;method&nbsp;of&nbsp;construction&nbsp;allows&nbsp;us&nbsp;to<br>
124 short-circuit&nbsp;creation&nbsp;of&nbsp;references&nbsp;to&nbsp;already-<br>
125 referenced&nbsp;instance&nbsp;methods.&nbsp;&nbsp;The&nbsp;key&nbsp;corresponding<br>
126 to&nbsp;the&nbsp;target&nbsp;is&nbsp;calculated,&nbsp;and&nbsp;if&nbsp;there&nbsp;is&nbsp;already<br>
127 an&nbsp;existing&nbsp;reference,&nbsp;that&nbsp;is&nbsp;returned,&nbsp;with&nbsp;its<br>
128 deletionMethods&nbsp;attribute&nbsp;updated.&nbsp;&nbsp;Otherwise&nbsp;the<br>
129 new&nbsp;instance&nbsp;is&nbsp;created&nbsp;and&nbsp;registered&nbsp;in&nbsp;the&nbsp;table<br>
130 of&nbsp;already-referenced&nbsp;methods.</tt></dd></dl>
131
132 <hr>
133 Data descriptors defined here:<br>
134 <dl><dt><strong>__dict__</strong></dt>
135 <dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
136 </dl>
137 <dl><dt><strong>__weakref__</strong></dt>
138 <dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
139 </dl>
140 </td></tr></table></td></tr></table><p>
141 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
142 <tr bgcolor="#eeaa77">
143 <td colspan=3 valign=bottom>&nbsp;<br>
144 <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
145
146 <tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
147 <td width="100%"><dl><dt><a name="-safeRef"><strong>safeRef</strong></a>(target, onDelete=None)</dt><dd><tt>Return&nbsp;a&nbsp;*safe*&nbsp;weak&nbsp;reference&nbsp;to&nbsp;a&nbsp;callable&nbsp;target<br>
148 &nbsp;<br>
149 target&nbsp;--&nbsp;the&nbsp;<a href="builtins.html#object">object</a>&nbsp;to&nbsp;be&nbsp;weakly&nbsp;referenced,&nbsp;if&nbsp;it's&nbsp;a<br>
150 &nbsp;&nbsp;&nbsp;&nbsp;bound&nbsp;method&nbsp;reference,&nbsp;will&nbsp;create&nbsp;a&nbsp;<a href="#BoundMethodWeakref">BoundMethodWeakref</a>,<br>
151 &nbsp;&nbsp;&nbsp;&nbsp;otherwise&nbsp;creates&nbsp;a&nbsp;simple&nbsp;weakref.<br>
152 onDelete&nbsp;--&nbsp;if&nbsp;provided,&nbsp;will&nbsp;have&nbsp;a&nbsp;hard&nbsp;reference&nbsp;stored<br>
153 &nbsp;&nbsp;&nbsp;&nbsp;to&nbsp;the&nbsp;callable&nbsp;to&nbsp;be&nbsp;called&nbsp;after&nbsp;the&nbsp;safe&nbsp;reference<br>
154 &nbsp;&nbsp;&nbsp;&nbsp;goes&nbsp;out&nbsp;of&nbsp;scope&nbsp;with&nbsp;the&nbsp;reference&nbsp;<a href="builtins.html#object">object</a>,&nbsp;(either&nbsp;a<br>
155 &nbsp;&nbsp;&nbsp;&nbsp;weakref&nbsp;or&nbsp;a&nbsp;<a href="#BoundMethodWeakref">BoundMethodWeakref</a>)&nbsp;as&nbsp;argument.</tt></dd></dl>
156 </td></tr></table><p>
157 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
158 <tr bgcolor="#55aa55">
159 <td colspan=3 valign=bottom>&nbsp;<br>
160 <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
161
162 <tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
163 <td width="100%"><strong>__cached__</strong> = '/home/mcfletch/OpenGL-dev/pydispatcher/pydispatch/__pycache__/saferef.cpython-310.pyc'<br>
164 <strong>__file__</strong> = '/home/mcfletch/OpenGL-dev/pydispatcher/pydispatch/saferef.py'<br>
165 <strong>__loader__</strong> = &lt;_frozen_importlib_external.SourceFileLoader object&gt;<br>
166 <strong>__name__</strong> = 'pydispatch.saferef'<br>
167 <strong>__package__</strong> = 'pydispatch'<br>
168 <strong>__spec__</strong> = ModuleSpec(name='pydispatch.saferef', loader=&lt;_f...h/OpenGL-dev/pydispatcher/pydispatch/saferef.py')<br>
169 <strong>im_func</strong> = '__func__'<br>
170 <strong>im_self</strong> = '__self__'</td></tr></table>
171 </body></html>