by cmiller1 · 3y ago · 0 comments
def do_info(self, line):
"""Display information about the current page."""
renderer = self.get_renderer()
def get_renderer_class():
return str(renderer.__class__).lstrip("<class '__main__.").rstrip("'>") if renderer else "None"
def get_page_lists(url):
return [l for l in self.list_lists() if self.list_has_url(url, l)]
def get_list_status(l):
if self.list_is_system(l):
return ""
status = "normal list"
if self.list_is_subscribed(l):
status = "subscription"
elif self.list_is_frozen(l):
status = "frozen list"
return f"({status})"
url, mode = unmode_url(self.current_url)
out = [
f"{renderer.get_page_title()}\n\n",
f"URL : {url}\n",
f"Mime : {renderer.get_mime()}\n",
f"Cache : {netcache.get_cache_path(url)}\n",
f"Renderer : {get_renderer_class()}\n\n"
]
lists = get_page_lists(url)
if lists:
out.append("Page appeared in the following lists:\n")
for l in lists:
out.append(f" • {l}\t{get_list_status(l)}\n")
return ''.join(out)Have you measured that your code is significantly faster than the original one?
So I would be curious to have some benchmark and would happily accept patches improving performances in ansicat.
But yes, benchmarks are very much necessary.