Working on improving the perf
This commit is contained in:
@@ -26,12 +26,12 @@ def to_html(item):
|
||||
class MyFt:
|
||||
def __init__(self, name, *args, **kwargs):
|
||||
self.name = name
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.children = args
|
||||
self.attrs = kwargs
|
||||
|
||||
def to_html(self):
|
||||
body_items = [to_html(item) for item in self.args]
|
||||
return f"<{self.name} {' '.join(f'{attr_map.get(k, k)}="{v}"' for k, v in self.kwargs.items())}>{' '.join(body_items)}</div>"
|
||||
body_items = [to_html(item) for item in self.children]
|
||||
return f"<{self.name} {' '.join(f'{attr_map.get(k, k)}="{v}"' for k, v in self.attrs.items())}>{' '.join(body_items)}</div>"
|
||||
|
||||
def __ft__(self):
|
||||
return NotStr(self.to_html())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import ast
|
||||
import base64
|
||||
import cProfile
|
||||
import functools
|
||||
import hashlib
|
||||
import importlib
|
||||
import inspect
|
||||
@@ -424,6 +425,7 @@ def split_host_port(url):
|
||||
|
||||
|
||||
def timed(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
start = time.perf_counter()
|
||||
result = func(*args, **kwargs)
|
||||
@@ -449,11 +451,14 @@ def timed(func):
|
||||
|
||||
|
||||
def profile_function(func):
|
||||
@functools.wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
profiler = cProfile.Profile()
|
||||
profiler.enable()
|
||||
result = func(*args, **kwargs)
|
||||
profiler.disable()
|
||||
try:
|
||||
profiler.enable()
|
||||
result = func(*args, **kwargs)
|
||||
finally:
|
||||
profiler.disable()
|
||||
|
||||
# Determine class name if any
|
||||
class_name = None
|
||||
@@ -522,4 +527,4 @@ class UnreferencedNamesVisitor(ast.NodeVisitor):
|
||||
:rtype:
|
||||
"""
|
||||
self.names.add(node.arg)
|
||||
self.visit_selected(node, ["value"])
|
||||
self.visit_selected(node, ["value"])
|
||||
Reference in New Issue
Block a user