[issue20774] collections.deque should ship with a stdlib json serializer

2020-11-05 Thread Ken Jin
Ken Jin added the comment: Sorry to butt into this conversation, but I wanted to add that I have interest in this feature - deques are the fourth most common container types I use in Python. Is there any way I can help to get this PR across the finish line? So far I've forked the PR,

[issue20774] collections.deque should ship with a stdlib json serializer

2019-03-05 Thread Lisa Roach
Lisa Roach added the comment: Serhiy might be right, it looks significantly worse with benchmarking: lisroach$ python3 -m timeit "import json; json.dumps(['test'])" 10 loops, best of 3: 2.73 usec per loop lisroach$ ./python.exe -m timeit "import json; json.dumps(['test'])" 1 loops,

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Seems there are reference leaks. And I afraid that importing a module for every serialized object can significantly hit the performance. Can you run some benchmarks? > An __json__ attribute would have to convert to a list first. Adding support > directly

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: Thanks Lisa. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-26 Thread Lisa Roach
Lisa Roach added the comment: I made PR 830 for this issue, it seems to be a nice feature to have in my opinion. Let me know if I should add some unit tests :) -- nosy: +lisroach pull_requests: +734 ___ Python tracker

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, one of the design goal for deques was to make them easily substitutable for lists when needed. This feature request is a nice-to-have that moves us a little closer. That said, I think a __json__ attribute is too big of a hammer for this simple

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: There is a difference. An __json__ attribute would have to convert to a list first. Adding support directly to the json module would allow the deque to be read directly. I think you all are leaning towards premature generalization and making this harder

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-05 Thread R. David Murray
R. David Murray added the comment: I disagree, I think a __json__ protocol is sensible. But this is why it needs to be discussed on python-dev or python-ideas first :) In the meantime adding deque support like we added enum support is reasonable, but IMO we shouldn't go to crazy adding

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: For now, just hardcoding deque support is fine. Support for a __json__ attribute or JSON array registry is a topic for another day. Even then, I don't think that within the standard library support for JSONification should have its responsibility shifted

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See issue27362 for more general approach. -- ___ Python tracker ___ ___

[issue20774] collections.deque should ship with a stdlib json serializer

2017-03-04 Thread Raymond Hettinger
Raymond Hettinger added the comment: See also, the same feature request from Tarek Ziadé, http://bugs.python.org/issue29663 , "collections.deque could be serialized in JSON as a simple array. The only thing we can lose in the process is the maxlen value, but I think it's a decent behaviour to

[issue20774] collections.deque should ship with a stdlib json serializer

2014-02-26 Thread Antoine Pitrou
Antoine Pitrou added the comment: The problem is that it would be deserialized as a list; this breaks the general expectation that serialization formats should round-trip. (yes, tuple already does this; but I think it is less of a problem for tuples, since the list API is a superset of the

[issue20774] collections.deque should ship with a stdlib json serializer

2014-02-26 Thread Gareth Rees
Gareth Rees added the comment: The JSON implementation uses these tests to determine how to serialize a Python object: isinstance(o, (list, tuple)) isinstance(o, dict) So any subclasses of list and tuple are serialized as a list, and any subclass of dict is serialized as an object.

[issue20774] collections.deque should ship with a stdlib json serializer

2014-02-25 Thread Chris Adams
New submission from Chris Adams: Currently the stdlib json module requires a custom serializer to avoid throwing a TypeError on collections.deque instances: Python 3.3.4 (default, Feb 12 2014, 09:35:54) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type help, copyright,

[issue20774] collections.deque should ship with a stdlib json serializer

2014-02-25 Thread R. David Murray
R. David Murray added the comment: json is only designed to serialize standard data types out of the box. Anything else is an extension. I presume you are asking for this because a deque looks more-or-less like a list. I'm not sure that's reason enough, but we'll see what others think.