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.
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
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
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
stage: - needs patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14886
___
___
Antoine Pitrou pit...@free.fr 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
Марк Коренберг socketp...@gmail.com 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))
Antoine Pitrou pit...@free.fr 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
Марк Коренберг socketp...@gmail.com 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).
--
New submission from Марк Коренберг socketp...@gmail.com:
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
Changes by Марк Коренберг socketp...@gmail.com:
--
type: - behavior
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14886
___
___
Python-bugs-list
Changes by Chris Rebert pyb...@rebertia.com:
--
nosy: +cvrebert
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14886
___
___
Python-bugs-list
Antoine Pitrou pit...@free.fr added the comment:
What difference does it make? Are you using __instancecheck__ perhaps?
--
nosy: +pitrou
versions: -Python 3.1, Python 3.4
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14886
Марк Коренберг socketp...@gmail.com 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
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
nosy: +ezio.melotti
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14886
___
___
Changes by Alexey Smirnov alexey.smir...@gmx.com:
--
nosy: +alexey-smirnov
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14886
___
___
15 matches
Mail list logo