[issue30248] Using boolean arguments in the _json module

2017-05-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset ac5bbd43bc7b769c13ae0412cb28a3521f4d4ff1 by Serhiy Storchaka in 
branch 'master':
bpo-30248: Convert boolean arguments only once in _json. (#1423)
https://github.com/python/cpython/commit/ac5bbd43bc7b769c13ae0412cb28a3521f4d4ff1


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-07 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This looks like a nice improvement.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Initially I was going to add explicit bool() calls in Python implementations, 
so that Python and C implementation behave the same in case of non-constant 
options. But then I figured out that is behavior is insane and we shouldn't 
guarantee anything in this case. If we don't bother to satisfy matching the 
behavior in Python and C implementations, this change is not worth to be 
mentioned in Misc/NEWS.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-03 Thread Josh Rosenberg

Josh Rosenberg added the comment:

So, incredibly minor note:

This will prevent a ridiculous use case of passing in a mutable object as the 
argument (say, a list), and mutating it between truthy and falsy values 
(appending or clearing) to toggle behaviors in an existing Encoder.

Note: As stated, this is a ridiculous use case, and I don't think we should be 
handcuffed by compatibility with an insane behavior that no one has likely ever 
used. The docs never guarantee that those values are examined live, so it's an 
implementation detail, and not a useful one at that. I just want to mention it 
so there is a small note in MISC/News or the like to document that slight tweak 
in observed behavior.

Otherwise, change looks good to me.

--
nosy: +josh.r

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
dependencies: +Core dump when use uninitialized _json objects

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-03 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +1529

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30248] Using boolean arguments in the _json module

2017-05-03 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

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).

--
components: Extension Modules
messages: 292861
nosy: bob.ippolito, ezio.melotti, rhettinger, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Using boolean arguments in the _json module
type: performance
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com