You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems to be a history artifact: the function was introduced in 400adb0 as a moved builtins.trunc(), while math.ceil/floor were here from the initial revision.
I suggested @skirpichev to open a separate issue for discussion and reference. Previously this change was hidden in a pile of unrelated changes.
Now I think that it is safe. This check is immediately followed by _PyObject_LookupSpecial() which calls _PyType_Lookup() which, after looking in the type cache, calls find_name_in_mro() which looks up tp_mro, and, if it has not yet been set, make the type ready.
I think that a similar code in the builtin round() can be removed as well. Other uses of _PyType_IsReady() and PyType_Ready() look more justified.
Activity
pythongh-111417: Remove unused code block in math.trunc()
Jason-Y-Z commentedon Oct 29, 2023
Created a small PR to remove the unused code block - #111454
serhiy-storchaka commentedon Nov 7, 2023
I suggested @skirpichev to open a separate issue for discussion and reference. Previously this change was hidden in a pile of unrelated changes.
Now I think that it is safe. This check is immediately followed by
_PyObject_LookupSpecial()which calls_PyType_Lookup()which, after looking in the type cache, callsfind_name_in_mro()which looks uptp_mro, and, if it has not yet been set, make the type ready.I think that a similar code in the builtin
round()can be removed as well. Other uses of_PyType_IsReady()andPyType_Ready()look more justified.skirpichev commentedon Nov 8, 2023
@serhiy-storchaka, in the end, it was your commit, that makes additional
PyType_Ready()(since 15d3d04) call here useless: 8ef3460.@Jason-Y-Z, I think you could reference that commit in you commit message. And remove similar code in
round(), of course.pythongh-111417: Remove unused code block in math.trunc() and builtin…
gh-111417: Remove unused code block in math.trunc() and round() (GH-1…
pythongh-111417: Remove unused code block in math.trunc() and round() (…
pythongh-111417: Remove unused code block in math.trunc() and round() (…