160 else:
161 if self.matrix[i, i]:
162 depStrings[i] = self.printIndexName(i) + ", " + depStrings[i]
163 _str += "%s <--- %s\n" % (self.printIndexName(i), depStrings[i])164
165 return _str
166
153 if depStrings[i] == None:
154 parents, _ = self.arch.getRegDependencies(i)
155 if not self.matrix[i, i] and not parents and verbose:
156 _str += "%s <-/- %s\n" % (157 self.printIndexName(i),
158 self.printIndexName(i),
159 )
254 _str = ""
255
256 for i in range(self.size):
257 _str += "%.3d" % i258 for j in range(self.size):
259 if (i, j) in self.matrix:
260 _str += "x"
f-strings are the fastest way to format strings as compared to the following methods:
%
format()
str.join
+
operator to concatinate stringTemplate.substitute
Some less preferred ways to format strings are the following:
from string import Template
menu = ('eggs', 'spam', 42.4)
old_order = "%s and %s: %.2f ¤" % menu # [consider-using-f-string]
beginner_order = menu[0] + " and " + menu[1] + ": " + str(menu[2]) + " ¤"
joined_order = " and ".join(menu[:2])
format_order = "{} and {}: {:0.2f} ¤".format(menu[0], menu[1], menu[2])
named_format_order = "{eggs} and {spam}: {price:0.2f} ¤".format(eggs=menu[0], spam=menu[1], price=menu[2])
template_order = Template('$eggs and $spam: $price ¤').substitute(eggs=menu[0], spam=menu[1], price=menu[2])
Consider using f-strings as shown below:
menu = ('eggs', 'spam', 42.4)
f_string_order = f"{menu[0]} and {menu[1]}: {menu[2]:0.2f} ¤"