Here's the relevant diff: https://github.com/python/cpython/pull/137968/files#diff-966...
Search is limited to 20 attributes and non-descriptors only to avoid arbitrary code execution.
I assume constructing AttributeErrors isn't highly performance sensitive.