Skip to content

Commit 5c88280

Browse files
authored
Merge pull request RustPython#2077 from youknowone/opt-int
Optimize int.__new__
2 parents 2174967 + aa899f6 commit 5c88280

File tree

4 files changed

+182
-132
lines changed

4 files changed

+182
-132
lines changed

Lib/test/test_int.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ def test_int_memoryview(self):
340340
def test_string_float(self):
341341
self.assertRaises(ValueError, int, '1.2')
342342

343-
@unittest.skip("TODO: RUSTPYTHON")
343+
# TODO: RUSTPYTHON
344+
@unittest.expectedFailure
344345
def test_intconversion(self):
345346
# Test __int__()
346347
class ClassicMissingMethods:

Lib/test/test_long.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ def check_format_1(self, x):
313313
with self.subTest(got=got):
314314
self.assertEqual(int(got, 0), x)
315315

316-
@unittest.skip # TODO: RUSTPYTHON
317316
def test_format(self):
318317
for x in special:
319318
self.check_format_1(x)
@@ -378,7 +377,6 @@ def test_long(self):
378377
# See bpo-34087
379378
self.assertRaises(ValueError, int, '\u3053\u3093\u306b\u3061\u306f')
380379

381-
@unittest.expectedFailure # TODO: RUSTPYTHON
382380
def test_long_a(self):
383381
self.assertRaises(ValueError, int, '-012395', 0)
384382

@@ -417,8 +415,9 @@ def check_float_conversion(self, n):
417415
"Got {}, expected {}.".format(n, actual, expected))
418416
self.assertEqual(actual, expected, msg)
419417

418+
# TODO: RUSTPYTHON
419+
@unittest.expectedFailure
420420
#@support.requires_IEEE_754
421-
@unittest.skip # TODO: RUSTPYTHON
422421
def test_float_conversion(self):
423422

424423
exact_values = [0, 1, 2,
@@ -830,8 +829,9 @@ def check_truediv(self, a, b, skip_small=True):
830829
self.assertEqual(expected, got, "Incorrectly rounded division {}/{}: "
831830
"expected {}, got {}".format(a, b, expected, got))
832831

832+
# TODO: RUSTPYTHON
833+
@unittest.expectedFailure
833834
#@support.requires_IEEE_754
834-
@unittest.skip
835835
def test_correctly_rounded_true_division(self):
836836
# more stringent tests than those above, checking that the
837837
# result of true division of ints is always correctly rounded.

vm/src/bytesinner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl ByteInnerNewOptions {
124124

125125
let mut data_bytes = vec![];
126126
for elem in elements {
127-
let v = objint::to_int(vm, &elem, &BigInt::from(10))?;
127+
let v = objint::to_int(vm, &elem)?;
128128
if let Some(i) = v.to_u8() {
129129
data_bytes.push(i);
130130
} else {

0 commit comments

Comments
 (0)