| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Hey @Fidget-Spinner, I'm a little lost here
|
Sorry, something went wrong.
| assert(init != NULL); | ||
| assert(PyFunction_Check(init)); | ||
| callable = sym_new_const(ctx, init); | ||
| sym_set_const(callable, init); |
There was a problem hiding this comment.
Sorry, something went wrong.
| PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type); | ||
| _Py_BloomFilter_Add(dependencies, type); | ||
| } | ||
| } |
There was a problem hiding this comment.
Same to bytecodes.c:
| } | |
| } | |
| self_or_null = sym_new_not_null(ctx); |
Sorry, something went wrong.
There was a problem hiding this comment.
Wait sorry, shouldn't this be sym_set_non_null?
Sorry, something went wrong.
There was a problem hiding this comment.
No. Please look at bytecodes.c. It's creating a new object, self. That's what _ALLOCATE_OBJECT does. So it should be a new non-null. This is same as the above where it grabs a new __init__ callable. In both of these cases, we do not set the existing symbol, but create a new one. This is a good learning point as it's tricky and requires observing bytecodes.c!
Sorry, something went wrong.
There was a problem hiding this comment.
Ah ok
Sorry, something went wrong.
Co-authored-by: Hai Zhu <haiizhu@outlook.com>
|
@Sacul0457 I'm going to push to this PR, as I think it's a little tricky to get right. Please add a test after I push. |
Sorry, something went wrong.
|
@Sacul0457 please add the following tests:
class MyPoint:
def __init__(self, x, y):
return None
def testfunc(n):
point_local = MyPoint
for _ in range(n):
p = point_local(1.0, 2.0)
p = point_local(1.0, 2.0)
class MyPoint:
def __init__(self, x, y):
return None
def testfunc(n):
for _ in range(n):
p = MyPoint(1.0, 2.0)
p = MyPoint(1.0, 2.0)
|
Sorry, something went wrong.
|
Sorry for the wait, I printed the uops trace for the second test and how can we tell if it is constant folded? ['_START_EXECUTOR', '_MAKE_WARM', '_SET_IP', '_CHECK_PERIODIC', '_CHECK_VALIDITY', '_ITER_CHECK_RANGE', '_GUARD_NOT_EXHAUSTED_RANGE',
'_ITER_NEXT_RANGE', '_SET_IP', '_SWAP_FAST_1', '_SPILL_OR_RELOAD', '_POP_TOP', '_CHECK_VALIDITY', '_SET_IP', '_LOAD_DEREF',
'_CHECK_VALIDITY', '_PUSH_NULL', '_LOAD_CONST_INLINE_BORROW', '_SPILL_OR_RELOAD', '_LOAD_CONST_INLINE_BORROW', '_SET_IP',
'_SPILL_OR_RELOAD', '_CHECK_OBJECT', '_ALLOCATE_OBJECT', '_CREATE_INIT_FRAME', '_PUSH_FRAME', '_CHECK_VALIDITY',
'_TIER2_RESUME_CHECK', '_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_EXIT_INIT_CHECK',
'_CHECK_VALIDITY', '_SET_IP', '_MAKE_HEAP_SAFE', '_RETURN_VALUE', '_GUARD_IP_RETURN_VALUE', '_GUARD_CODE_VERSION_RETURN_VALUE',
'_CHECK_VALIDITY', '_SET_IP', '_SWAP_FAST_2', '_POP_TOP', '_CHECK_VALIDITY', '_SET_IP', '_LOAD_DEREF', '_CHECK_VALIDITY',
'_PUSH_NULL', '_LOAD_CONST_INLINE_BORROW', '_SPILL_OR_RELOAD', '_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_SPILL_OR_RELOAD',
'_CHECK_OBJECT', '_ALLOCATE_OBJECT', '_CREATE_INIT_FRAME', '_PUSH_FRAME', '_CHECK_VALIDITY', '_TIER2_RESUME_CHECK',
'_LOAD_CONST_INLINE_BORROW', '_SET_IP', '_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_EXIT_INIT_CHECK', '_CHECK_VALIDITY',
'_SET_IP', '_MAKE_HEAP_SAFE', '_RETURN_VALUE', '_GUARD_IP_RETURN_VALUE', '_GUARD_CODE_VERSION_RETURN_VALUE', '_CHECK_VALIDITY', '_SET_IP', '_SWAP_FAST_2', '_POP_TOP', '_JUMP_TO_TOP', ...] |
Sorry, something went wrong.
|
@Sacul0457 that's strange, seems like it's not being constant folded in the second case. Let me fix that. |
Sorry, something went wrong.
|
Oh alright. I'm probably going to bed now, please feel free to add the tests too as I don't want to hold up this PR being merged. Thank you! |
Sorry, something went wrong.
|
Sorry Sacul, I forgot to mention that you can't nest MyPoint in the test, it needs to be a global to be promoted. My bad, and good night! |
Sorry, something went wrong.
There was a problem hiding this comment.
Thank you for splitting the ops in bytecodes.c Sacul.
Sorry, something went wrong.
…ler uops (pythonGH-148433)" This reverts commit 18d7d90.
…pythonGH-148433) Co-authored-by: Hai Zhu <haiizhu@outlook.com> Co-authored-by: Ken Jin <kenjin4096@gmail.com>
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.