mirror of
https://github.com/python/cpython.git
synced 2025-08-23 18:24:46 +00:00
gh-90213: Speed up right shifts of negative integers (GH-30277)
This commit is contained in:
parent
4b297a9ffd
commit
0ed91a26fe
3 changed files with 76 additions and 30 deletions
|
@ -985,6 +985,10 @@ class LongTest(unittest.TestCase):
|
|||
self.assertEqual((-1122) >> 9, -3)
|
||||
self.assertEqual(2**128 >> 9, 2**119)
|
||||
self.assertEqual(-2**128 >> 9, -2**119)
|
||||
# Exercise corner case of the current algorithm, where the result of
|
||||
# shifting a two-limb int by the limb size still has two limbs.
|
||||
self.assertEqual((1 - BASE*BASE) >> SHIFT, -BASE)
|
||||
self.assertEqual((BASE - 1 - BASE*BASE) >> SHIFT, -BASE)
|
||||
|
||||
def test_big_rshift(self):
|
||||
self.assertEqual(42 >> 32, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue