[issue14886] json C vs pure-python implementation difference

2018-08-17 Thread Stefan Behnel
Stefan Behnel added the comment: FWIW, the C implementation of the sequence encoder uses PySequence_Fast(), so adding a lower priority instance check that calls the same encoding function would solve this. https://github.com/python/cpython/blob/cfa797c0681b7fef47cf93955fd06b54ddd09a7f/Module

[issue14886] json C vs pure-python implementation difference

2018-08-17 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: We have received a notification about this bug for 3.5 -- nosy: +matrixise versions: +Python 3.5, Python 3.6, Python 3.7, Python 3.8 -Python 2.7, Python 3.2, Python 3.3 ___ Python tracker

[issue14886] json C vs pure-python implementation difference

2012-09-28 Thread Thomas Lee
Thomas Lee added the comment: FWIW, I think Mark's right here. I'm +1 on the implementations being consistent. Seems like a potentially nasty surprise if you move from one implementation to the other and, lacking awareness of this quirk, design your algorithm around semantics. I think this was

[issue14886] json C vs pure-python implementation difference

2012-09-26 Thread Ezio Melotti
Changes by Ezio Melotti : -- stage: -> needs patch ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue14886] json C vs pure-python implementation difference

2012-05-24 Thread Марк Коренберг
Марк Коренберг added the comment: Inconsistency is bother me. If I specify indent in dumps(), I will have one semantics, else other ones. Why not to fix pure-python implementation using "type(o) in (list, tuple)" ? This is faster too (as I think). --

[issue14886] json C vs pure-python implementation difference

2012-05-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Well, __class_ = list is my problem, but python's problem is that it > uses different approaches in C and python implementation. Well, by construction a C accelerator will use the fastest method available within what the API's specification allows. The json A

[issue14886] json C vs pure-python implementation difference

2012-05-24 Thread Марк Коренберг
Марк Коренберг added the comment: Well, __class_ = list is my problem, but python's problem is that it uses different approaches in C and python implementation. P.S. I don't want to subclass list, as I don't want things like this: x = pseudo_list(iter(xrange(10)) x.append('test') print len(x)

[issue14886] json C vs pure-python implementation difference

2012-05-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: > class pseudo_list(object): > __class__ = list # fake isinstance Why not inherit from list directly? Setting __class__ to something else isn't widely supported in the Python code base. It may work or may not work, depending on the API, but it's not someth

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Alexey Smirnov
Changes by Alexey Smirnov : -- nosy: +alexey-smirnov ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Марк Коренберг
Марк Коренберг added the comment: #!/usr/bin/python2.7 import json class pseudo_list(object): __class__ = list # fake isinstance def __init__(self, iterator): self._saved_iterator = iterator def __iter__(self): return self._saved_iterator class myenc(json.JSONEnc

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Antoine Pitrou
Antoine Pitrou added the comment: What difference does it make? Are you using __instancecheck__ perhaps? -- nosy: +pitrou versions: -Python 3.1, Python 3.4 ___ Python tracker _

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Chris Rebert
Changes by Chris Rebert : -- nosy: +cvrebert ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Марк Коренберг
Changes by Марк Коренберг : -- type: -> behavior ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.p

[issue14886] json C vs pure-python implementation difference

2012-05-23 Thread Марк Коренберг
New submission from Марк Коренберг : Pure-python implementation: if isinstance(o, (list, tuple)): C implementation: if (PyList_Check(obj) || PyTuple_Check(obj)) This make real difference (!) in my code. So, please change pure-python implementation to: if type(o) in (list, tuple): O