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 serhiy.storchaka
Recipients bob.ippolito, ezio.melotti, rhettinger, serhiy.storchaka
Date 2017-05-03.08:38:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1493800695.72.0.112994453765.issue30248@psf.upfronthosting.co.za>
In-reply-to
Content
Currently PyObject_IsTrue() is called every time when bool attributes (_json.Scanner.strict, _json.Encoder.sort_keys, _json.Encoder.skipkeys) are used in C acceleration of the json module. PyObject_IsTrue() is fast when the argument is a bool, but in any case this isn't efficient and is cumbersome. It is better to convert Python bool to C boolean value only once when create an object, as already is done for _json.Encoder.allow_nan and for most other boolean values in extension modules.

Proposed patch simplifies and optimizes the code by making arguments strict, sort_keys and skipkeys be converted only once at argument parsing time.

The patch changes behavior in the case when the boolean value of the argument is not constant. But this is very bad practice, we may ignore this obscure case (as ignore the case when the boolean value of the container doesn't consistent with its content, see issue27613).
History
Date User Action Args
2017-05-03 08:38:15serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, bob.ippolito, ezio.melotti
2017-05-03 08:38:15serhiy.storchakasetmessageid: <1493800695.72.0.112994453765.issue30248@psf.upfronthosting.co.za>
2017-05-03 08:38:15serhiy.storchakalinkissue30248 messages
2017-05-03 08:38:15serhiy.storchakacreate