MCPcopy Index your code
hub / github.com/python/cpython / slow_format

Method slow_format

Lib/test/test_long.py:293–305  ·  view source on GitHub ↗
(self, x, base)

Source from the content-addressed store, hash-verified

291 self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2))
292
293 def slow_format(self, x, base):
294 digits = []
295 sign = 0
296 if x < 0:
297 sign, x = 1, -x
298 while x:
299 x, r = divmod(x, base)
300 digits.append(int(r))
301 digits.reverse()
302 digits = digits or [0]
303 return '-'[:sign] + \
304 {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
305 "".join("0123456789abcdef"[i] for i in digits)
306
307 def check_format_1(self, x):
308 for base, mapper in (2, bin), (8, oct), (10, str), (10, repr), (16, hex):

Callers 1

check_format_1Method · 0.95

Calls 3

appendMethod · 0.45
reverseMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected