[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-16 Thread STINNER Victor
STINNER Victor added the comment: Cool. I always wanted to implement something similar. Nice work Naoki! -- nosy: +vstinner ___ Python tracker ___ _

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-16 Thread INADA Naoki
INADA Naoki added the comment: I confirmed django_template is `hasattr`-heavy benchmark. Functionwas called by... ncalls tottime cumtime {built-in method builtins.hasattr} <- 10.0000.000 /home/inada-n/local/p

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-16 Thread INADA Naoki
INADA Naoki added the comment: New changeset 378edee0a3b913d60653dc17dfe61d83405a8135 by INADA Naoki in branch 'master': bpo-32544: Speed up hasattr() and getattr() (GH-5173) https://github.com/python/cpython/commit/378edee0a3b913d60653dc17dfe61d83405a8135 -- ___

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-16 Thread INADA Naoki
Change by INADA Naoki : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___ ___ Py

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-16 Thread INADA Naoki
INADA Naoki added the comment: I run pyperformance. It seems django_template is significant faster. # Without PGO+LTO ./python -m perf compare_to -G --min-speed=2 default.json patched.json Slower (6): - scimark_monte_carlo: 217 ms +- 9 ms -> 237 ms +- 10 ms: 1.09x slower (+9%) - scimark_lu: 32

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-15 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I considered the idea of implementing _PyObject_GetAttrWithoutError() for issue31572, but dropped it because the code simplification was too small. But if this has performance benefits I'm +1 to implementing it. I'll update my still open PRs to use this API

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-13 Thread INADA Naoki
Change by INADA Naoki : -- keywords: +patch pull_requests: +5026 stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list

[issue32544] Speed up hasattr(o, name) and getattr(o, name, default)

2018-01-13 Thread INADA Naoki
New submission from INADA Naoki : ABCMeta.__new__ calls `getattr(value, "__isabstractmethod__", False)` many times. https://github.com/python/cpython/blob/0f31c74fcfdec8f9e6157de2c366f2273de81677/Lib/abc.py#L135-L142 Since metaclass is used by subclasses, it checks all members of all subclasses