This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Eric Lippert
Recipients Eric Lippert
Date 2018-08-30.17:27:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535650041.35.0.56676864532.issue34551@psf.upfronthosting.co.za>
In-reply-to
Content
In _PyFunction_FastCallDict we have local nk assigned to be the size of a dictionary, and then local i is assigned to twice the size of the same dictionary, and then nk is assigned to half of i, which it already is:

   nk = (kwargs != NULL) ? PyDict_GET_SIZE(kwargs) : 0;
   if (nk != 0) {
     ...
     pos = i = 0;
     while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
       ...
       i += 2;
     }
     nk = i / 2;

I am attempting to understand the performance characteristics of this hot path, and I spent far too long trying to figure out why nk was being assigned a value it already has. :)

I propose that the redundant store be replaced with an assertion that i/2 is equal to nk.

I will submit a pull request presently.
History
Date User Action Args
2018-08-30 17:27:21Eric Lippertsetrecipients: + Eric Lippert
2018-08-30 17:27:21Eric Lippertsetmessageid: <1535650041.35.0.56676864532.issue34551@psf.upfronthosting.co.za>
2018-08-30 17:27:21Eric Lippertlinkissue34551 messages
2018-08-30 17:27:21Eric Lippertcreate