Optimize the UI by caching convert_to_markdown calls

This commit is contained in:
oobabooga 2024-03-10 20:09:34 -07:00
parent 056717923f
commit afadc787d7

View File

@ -2,6 +2,7 @@ import html
import os import os
import re import re
import time import time
import functools
from pathlib import Path from pathlib import Path
import markdown import markdown
@ -47,6 +48,7 @@ def replace_blockquote(m):
return m.group().replace('\n', '\n> ').replace('\\begin{blockquote}', '').replace('\\end{blockquote}', '') return m.group().replace('\n', '\n> ').replace('\\begin{blockquote}', '').replace('\\end{blockquote}', '')
@functools.lru_cache(maxsize=512)
def convert_to_markdown(string): def convert_to_markdown(string):
# Blockquote # Blockquote