-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-139393: fix _CALL_LEN
JIT tests for tuples
#139394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
|
||
_testinternalcapi = import_helper.import_module("_testinternalcapi") | ||
|
||
from _testinternalcapi import TIER2_THRESHOLD | ||
from _testinternalcapi import _PY_NSMALLPOSINTS, TIER2_THRESHOLD | ||
|
||
#For test of issue 136154 | ||
GLOBAL_136154 = 42 | ||
|
@@ -2093,6 +2093,10 @@ def testfunc(n): | |
self.assertNotIn("_GUARD_TOS_INT", uops) | ||
|
||
def test_call_len_known_length_small_int(self): | ||
# Make sure that len(t) is optimized for a tuple of length 5. | ||
# See https://github.com/python/cpython/issues/139393. | ||
self.assertGreater(_PY_NSMALLPOSINTS, 5) | ||
|
||
def testfunc(n): | ||
x = 0 | ||
for _ in range(n): | ||
|
@@ -2113,13 +2117,17 @@ def testfunc(n): | |
self.assertNotIn("_POP_TOP_LOAD_CONST_INLINE_BORROW", uops) | ||
|
||
def test_call_len_known_length(self): | ||
# Make sure that len(t) is optimized for a tuple of length 2048. | ||
# See https://github.com/python/cpython/issues/139393. | ||
self.assertLess(_PY_NSMALLPOSINTS, 2048) | ||
|
||
def testfunc(n): | ||
class C: | ||
t = tuple(range(300)) | ||
t = tuple(range(2048)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using a hardcoded magic number, it would be nice if we used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am actually unsure whether we need hardcoding here actually because of the JIT. I'll check if changing it to a compile-time known value is necessary or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's what I feared. While the test still passes, the uops will be different. I don't remember when we have some inlined computations There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I think we should make such change at other places as well. If you want to, let's open a separate issue. |
||
|
||
x = 0 | ||
for _ in range(n): | ||
if len(C.t) == 300: # comparison + guard removed | ||
if len(C.t) == 2048: # comparison + guard removed | ||
x += 1 | ||
return x | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.