New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
merge json library with latest simplejson 2.0.x #48386
Comments
simplejson 2.0.3 includes major performance enhancements (both in Python I will need some help with 3.0 since I am not well versed in the changes How should I go about this? |
Can you write a patch against python trunk ? :-) |
Sure, but that doesn't port it to Python 3.0 :) |
Still, as Victor suggests, the first step for porting it to 3.0 |
patch to r66961 of trunk is attached. |
About the patch: are those lines really needed? + PyScannerType.tp_getattro = PyObject_GenericGetAttr; I've never used them. What happens if the slots are left empty, and let PyType_Ready() do the rest? |
You're probably right, I don't remember what code I was using as a |
Actually, if I remove those lines from the equivalent module in simplejson File "/Users/bob/src/simplejson/simplejson/decoder.py", line 307, in |
Why aren't the functions pointers in the structs itself? As a procedural note, it seems like this patch is a complete rewrite of |
I don't recall exactly why they aren't in the struct itself, it may not It's not really a complete rewrite, the encoding path is largely the Anyway, there is no further work planned for simplejson. It's done |
Attached is a new diff, one byte fix to the float parser when parsing JSON |
Bumping priority a bit. |
http://codereview.appspot.com/7311/diff/1/8 http://codereview.appspot.com/7311/diff/1/8#newcode55 http://codereview.appspot.com/7311/diff/1/8#newcode71 http://codereview.appspot.com/7311/diff/1/8#newcode76 http://codereview.appspot.com/7311/diff/1/8#newcode104 http://codereview.appspot.com/7311/diff/1/8#newcode107 http://codereview.appspot.com/7311/diff/1/8#newcode111 http://codereview.appspot.com/7311/diff/1/8#newcode127 http://codereview.appspot.com/7311/diff/1/8#newcode132 http://codereview.appspot.com/7311/diff/1/8#newcode290 http://codereview.appspot.com/7311/diff/1/8#newcode317 http://codereview.appspot.com/7311/diff/1/9 http://codereview.appspot.com/7311/diff/1/9#newcode196 http://codereview.appspot.com/7311/diff/1/9#newcode215 http://codereview.appspot.com/7311/diff/1/9#newcode733 http://codereview.appspot.com/7311/diff/1/9#newcode1320 http://codereview.appspot.com/7311/diff/1/9#newcode1528 http://codereview.appspot.com/7311/diff/1/9#newcode2025 |
By "next patch" I'm referring to a currently nonexistent patch that --- http://codereview.appspot.com/7311/diff/1/8 http://codereview.appspot.com/7311/diff/1/8#newcode55 http://codereview.appspot.com/7311/diff/1/8#newcode71 http://codereview.appspot.com/7311/diff/1/8#newcode76 http://codereview.appspot.com/7311/diff/1/8#newcode104 http://codereview.appspot.com/7311/diff/1/8#newcode107 http://codereview.appspot.com/7311/diff/1/8#newcode111 http://codereview.appspot.com/7311/diff/1/8#newcode127 http://codereview.appspot.com/7311/diff/1/8#newcode132 http://codereview.appspot.com/7311/diff/1/8#newcode290 http://codereview.appspot.com/7311/diff/1/8#newcode317 http://codereview.appspot.com/7311/diff/1/9 http://codereview.appspot.com/7311/diff/1/9#newcode196 http://codereview.appspot.com/7311/diff/1/9#newcode215 http://codereview.appspot.com/7311/diff/1/9#newcode733 http://codereview.appspot.com/7311/diff/1/9#newcode1320 http://codereview.appspot.com/7311/diff/1/9#newcode1528 http://codereview.appspot.com/7311/diff/1/9#newcode2025 |
Bob, any news on this? |
patch to r69662 is attached as json_issue4136_r69662.diff -- note that |
A bunch of comments from a quick look:
|
Bob, here is a small example showing how easy it is to encounter the GC from json import JSONDecoder
import weakref
import gc
class MyObject(object):
def __init__(self):
self.decoder = JSONDecoder(parse_constant=self.parse_constant)
def parse_constant(self, *args, **kargs):
""" XXX """
wr = weakref.ref(MyObject())
gc.collect()
print wr() |
Old-style relative imports and the way that it does join are there because It will probably take another week or two for me to implement those things |
New patch implementing cyclic GC, new-style relative imports, no lines >80 |
Thanks for the update. I'll try to take the time for a review in less |
Honestly I'm not sure when I'm going to find the time and motivation to |
I think reformatting line length should not hold-up this patch. That is |
They are essentially the same except the relative imports are changed to The way I see it, the names have to change anyway, so other things might |
Martin, is this patch good-to-go? |
What needs to happen next for this patch to go forward? |
Well, if Bob has addressed all of Martin's comments, I suppose it can |
All of the comments are addressed. I am not going to go through the |
The patch in its current form is fine with me, please apply (OTOH, I |
Bob, please go ahead and commit. I don't see any advantage to letting |
r70443 in trunk |
Reopening so that we don't forget to merge it in py3k :) |
It might not be bad. I read through the patch a saw that it uses only |
This change should be ported to py3k sometime before the first beta. |
Here's a half-baked patch against py3k. It resolves all the conflicts For example, json.dumps(b"hi") works, but not json.dumps([b"hi", "hi"]) |
There is the problem in the current py3k version of json. b"hi" can be >>> json.dumps(b"hi")
'"hi"'
>>> json.dumps([b"hi"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/antoine/py3k/__svn__/Lib/json/__init__.py", line 230, in dumps
return _default_encoder.encode(obj)
File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 367, in encode
chunks = list(self.iterencode(o))
File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 306, in
_iterencode
for chunk in self._iterencode_list(o, markers):
File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 204, in
_iterencode_list
for chunk in self._iterencode(value, markers):
File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 317, in
_iterencode
for chunk in self._iterencode_default(o, markers):
File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 323, in
_iterencode_default
newobj = self.default(o)
File "/home/antoine/py3k/__svn__/Lib/json/encoder.py", line 344, in
default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'hi' is not JSON serializable |
Christian:
|
Updated patch:
To be done:
|
Here is an updated patch, completely removing the |
(by the way, all tests pass) |
It would be better to have a patch that diff's from the current 2.7 |
How am I supposed to produce this patch? |
The idea is to ignore the current 3.0 version and just redo the 2-to-3 |
+1 for Raymond's suggestion The 3.0 version of json was more like a last minute patch work than |
I'll take a stab at doing it Raymond's way this weekend. |
Since no other patches were proposed, I applied Antoine's patch in r72194. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: