Skip to content

Commit

Permalink
delete hexadecimal addresses specified in the repr of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
furkanonder committed Oct 11, 2023
1 parent 4832574 commit 45ffccf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/akarsu/akarsu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import sys
import types
from typing import Any, Final, cast
Expand All @@ -20,13 +21,18 @@
(EVENTS.STOP_ITERATION, "STOP ITERATION"),
)
EVENT_SET: Final[int] = EVENTS.CALL + sum(ev for ev, _ in TRACKED_EVENTS)
PATTERN: Final[str] = r" at 0x[0-9a-f]+"


class Akarsu:
def __init__(self, code: str, file_name: str) -> None:
self.code = code
self.file_name = file_name

def format_func_name(self, event: tuple[str, str, str]) -> tuple[str, str, str]:
event_type, file_name, func_name = event
return (event_type, file_name, re.sub(PATTERN, "", func_name))

def profile(self) -> list[tuple[str, str, str]]:
events = []

Expand Down Expand Up @@ -64,6 +70,10 @@ def record_call(
MONITOR.set_events(TOOL, 0)
MONITOR.free_tool_id(TOOL)

events = [e for e in events[2:-3] if "____wrapper____" not in e[2]]
events = [
self.format_func_name(event)
for event in events[2:-3]
if "____wrapper____" not in event[2]
]

return events

0 comments on commit 45ffccf

Please sign in to comment.