summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2023-03-24 09:44:12 -0400
committerLeonard Richardson <leonardr@segfault.org>2023-03-24 09:44:12 -0400
commit5003f474b26505c9bfc6c44d1f78af76ff8f2634 (patch)
treebf2cfcad8fed19425339d76a2a3978e416d8d37a
parenta342497cb81f01384d61e467daf91540369d4fc3 (diff)
Using a format string is very slightly slower than just adding all the bits of the string together.
-rw-r--r--bs4/element.py2
-rw-r--r--bs4/formatter.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/bs4/element.py b/bs4/element.py
index 4f1372a..630fd96 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -1818,7 +1818,7 @@ class Tag(PageElement):
void_element_closing_slash = formatter.void_element_close_prefix or ''
# Put it all together.
- return f'<{closing_slash}{prefix}{self.name}{attribute_string}{void_element_closing_slash}>'
+ return '<' + closing_slash + prefix + self.name + attribute_string + void_element_closing_slash + '>'
def _should_pretty_print(self, indent_level=1):
"""Should this tag be pretty-printed?
diff --git a/bs4/formatter.py b/bs4/formatter.py
index 83cc1c5..c821318 100644
--- a/bs4/formatter.py
+++ b/bs4/formatter.py
@@ -97,7 +97,7 @@ class Formatter(EntitySubstitution):
else:
indent = ' '
self.indent = indent
-
+
def substitute(self, ns):
"""Process a string that needs to undergo entity substitution.
This may be a string encountered in an attribute value or as