@@ -31,7 +31,6 @@ import opcode
3131import os
3232import types
3333from warnings import warn
34- from weakref import WeakSet
3534
3635from line_profiler._diagnostics import (
3736 WRAP_TRACE, SET_FRAME_LOCAL_TRACE, USE_LEGACY_TRACE
@@ -1067,9 +1066,6 @@ cdef class LineProfiler:
10671066 _managers = {}
10681067 # type: ClassVar[dict[bytes, int]], bytes = bytecode
10691068 _all_paddings = {}
1070- # type: ClassVar[dict[int, weakref.WeakSet[LineProfiler]]],
1071- # int = func id
1072- _all_instances_by_funcs = {}
10731069
10741070 def __init__ (self , *functions ,
10751071 wrap_trace = None , set_frame_local_trace = None ):
@@ -1165,15 +1161,6 @@ datamodel.html#user-defined-functions
11651161 func.__code__ = code
11661162 except AttributeError as e:
11671163 func.__func__.__code__ = code
1168- # XXX: if we no longer re-pad the bytecode, do we still need
1169- # to do bookkeeping on which profiler instances follow which
1170- # function objects?
1171- try :
1172- profilers_to_update = self ._all_instances_by_funcs[func_id]
1173- profilers_to_update.add(self )
1174- except KeyError :
1175- profilers_to_update = WeakSet({self })
1176- self ._all_instances_by_funcs[func_id] = profilers_to_update
11771164 # Maintain `.dupes_map` (legacy)
11781165 try :
11791166 self .dupes_map[base_co_code].append(code)
@@ -1213,21 +1200,17 @@ datamodel.html#user-defined-functions
12131200 # because Cython shim code objects don't support local
12141201 # events
12151202 code = code.replace(co_filename = cython_source)
1216- profilers_to_update = {self }
12171203 # Update `._c_code_map` and `.code_hash_map` with the new line
1218- # hashes on `self` (and other instances profiling the same
1219- # function if we padded the bytecode)
1220- for instance in profilers_to_update:
1221- prof = < LineProfiler> instance
1222- try :
1223- line_hashes = prof.code_hash_map[code]
1224- except KeyError :
1225- line_hashes = prof.code_hash_map[code] = []
1226- for code_hash in code_hashes:
1227- line_hash = < int64> code_hash
1228- if not prof._c_code_map.count(line_hash):
1229- line_hashes.append(line_hash)
1230- prof._c_code_map[line_hash]
1204+ # hashes
1205+ try :
1206+ line_hashes = self .code_hash_map[code]
1207+ except KeyError :
1208+ line_hashes = self .code_hash_map[code] = []
1209+ for code_hash in code_hashes:
1210+ line_hash = < int64> code_hash
1211+ if not self ._c_code_map.count(line_hash):
1212+ line_hashes.append(line_hash)
1213+ self ._c_code_map[line_hash]
12311214
12321215 self .functions.append(func)
12331216
0 commit comments