Skip to content

PERF,TASK: Audit PyObject_GetAttr usages #27120

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

Open
seberg opened this issue Aug 6, 2024 · 1 comment
Open

PERF,TASK: Audit PyObject_GetAttr usages #27120

seberg opened this issue Aug 6, 2024 · 1 comment

Comments

@seberg
Copy link
Member

seberg commented Aug 6, 2024

In many places we still use PyObject_GetAttrString or PyObject_GetAttr. It would be good to:

  1. Ensure we use PyObject_GetAttr with an interned string wherever the lookup may be in a performance relevant code branch. Exceptions are for example:
    • Anything that happens only once, e.g. import time.
    • It may not be worth making e.g. error paths more complicated just to use this.
  2. Use PyObject_GetOptionalAttr whenever a possible AttributeError is ignored (or all exceptoins, although it's best not to ignore all exceptions).

Creating the unicode objects isn't that fast, I think. And PyObject_GetOptionalAttr can be massively faster if the attribute isn't found because it can avoid the error creation.

@ashwani-dumca
Copy link

Hi @seberg , Thank You for helping me trace and fix the issue : PR for the same is: #27449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy