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
Performance degradation of attribute accesses in Python 3.7.4 #82722
Comments
After upgrading from Python 3.7.3 to Python 3.7.4, we noticed an increased runtime of about 50% in some tests of our application. After some testing we constructed the following hypothesis: Accessing instance attributes of classes that define a custom metaclass take more time in Python 3.7.4. The access takes the more time the more classes are in the MRO of the concerning class (in other words the more base classes the concerning class has got). We verified the hypothesis by creating a minimal example (file attached) that produced the output at the bottom. (The index defines the number of base classes. The four variants are with/without a metaclass and with simple/multiple inheritance. The kind of inheritance has no influence on the runtime.) In Python 3.7.4 (in contrast to 3.7.3 and 3.8), you can see that the usage of a metaclass results in a linear increase of the runtime of attribute accesses depending on the number of base classes. We could also identify the issue/commit that introduced the performance issue: In the Python 3.8 branch, the performance issue seems to be resolved by: Will this performance issue be addressed in a future 3.7 version (e.g. 3.7.6) or is it in your optinion sufficient that the issue seems to be resolved in 3.8? Python 3.7.3 (constant runtime) 3.668036e-08 noMetaBaseX[1].attr Python 3.7.4 (see lines marked with ->) 4.042378e-08 noMetaBaseX[1].attr Python 3.8.0rc1 (constant runtime) 4.045787e-08 noMetaBaseX[1].attr |
I just ran the test with Python 3.7.5: As expected, I got the same results as in Python 3.7.4. Nevertheless, thanks for the response. So we will stay with Python 3.7.3 for now and switch to Python 3.8 as soon as possible. |
Closing as this is resolved in 3.8 and we won't do anything about 3.7. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: