Skip to content

Commit af098a2

Browse files
committed
Minor optimization
1 parent 654121f commit af098a2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

line_profiler/_line_profiler.pyx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,8 @@ cdef class LineProfiler:
413413
func.__code__ = code
414414
except AttributeError as e:
415415
func.__func__.__code__ = code
416+
else: # No re-padding -> no need to update the neighbors
417+
neighbors = {self}
416418
# TODO: Since each line can be many bytecodes, this is kinda
417419
# inefficient
418420
# See if this can be sped up by not needing to iterate over
@@ -446,7 +448,8 @@ cdef class LineProfiler:
446448
code = code.replace(co_filename=cython_source)
447449
neighbors = {self}
448450
# Update `._c_code_map` and `.code_hash_map` with the new line
449-
# hashes on `self` and other instances profiling the same func
451+
# hashes on `self` (and other instances profiling the same
452+
# function if we padded the bytecode)
450453
for instance in neighbors:
451454
prof = <LineProfiler>instance
452455
try:

0 commit comments

Comments
 (0)