classification
Title: Add simplejson to Python 2.6/3.0 standard library
Type: feature request
Components: Library (Lib) Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: benjamin.peterson, bob.ippolito, brett.cannon, christian.heimes, georg.brandl, pjenvey
Priority: critical Keywords: patch

Created on 2008-05-03 21:52 by bob.ippolito, last changed 2008-05-16 22:35 by benjamin.peterson.

Files
File name Uploaded Description Edit Remove
simplejson-1.9.tar.gz bob.ippolito, 2008-05-03 21:52 simplejson 1.9 sdist
json.rst benjamin.peterson, 2008-05-04 18:09
json_py3k.patch christian.heimes, 2008-05-08 01:31
Messages
msg66176 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-03 21:52
Attached is the tarball for simplejson 1.9, the proposed version to be
included in the stdlib.

Estimated work remaining:

 * Rename simplejson to json
 * Build simplejson/_speedups.c from Modules/Setup and Windows projects
 * Convert documentation to Python docs
 * Port to Python 3.0
msg66177 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-03 22:01
This work might be a good thing to a do on a Bazaar branch.
msg66178 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-03 22:15
The most critical steps are to get the code building and to get the tests 
passing. Once that is working the code can be checked in and the other 
steps (docs, PEP 7/8, 3.0 conversion) can happen after the fact.
msg66179 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-03 22:19
Yeah, either make a bzr branch or an ordinary svn branch. If you need
some help with the C code I can be of assistance. I'm in #python-dev.
Let's coordinate the next steps there.
msg66180 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-03 22:20
On Sat, May 3, 2008 at 3:19 PM, Christian Heimes <report@bugs.python.org> wrote:
>
>  Christian Heimes <lists@cheimes.de> added the comment:
>
>  Yeah, either make a bzr branch or an ordinary svn branch. If you need
>  some help with the C code I can be of assistance. I'm in #python-dev.
>  Let's coordinate the next steps there.

I am about to create a bzr branch in my personal directory named
issue2750-simplejson.
msg66181 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-03 22:24
Branch is at http://code.python.org/python/users/brett/issue2750-
simplejson/ .
msg66182 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-03 22:51
Just so it is documented, Bob said on IRC that we do not need to keep 
compatibility with any specific version of Python.
msg66183 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-03 22:52
I'll do PEP 8 review.
msg66185 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-04 01:12
The json package is in brett's branch, integrates with the test suite,
builds the C extension and passes all tests (at least on OS X and Linux
UCS2 and UCS4).

Missing the docs and python 3.0 support still, otherwise things look good.
msg66186 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-04 01:33
I'm going to handle the docs, too.
msg66193 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-04 07:03
One problem with the way the patch is now is that it will fail on non-
CPython interpreters the way it is currently coded. For instance, 
json/decoder.py completely assumes that importing _json will succeed. Same 
with the test suite.

Will need to tweak the code so that it will run on PyPy, etc., where there 
is no C extensions.

But that does not need to hold up committing the code. If Christian and 
Benjamin think the code is in good shape we can commit now and fix in svn.
msg66194 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-04 07:09
It doesn't work on alternate implementations right now anyway, because
it (ab)uses some sre APIs that aren't widely implemented outside of cpython.
msg66195 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-04 07:50
Ouch. Well then hopefully either they will get implemented or some way to 
not rely on them can be developed.
msg66197 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-04 08:04
it's isolated to json.scanner, if that was re-implemented in more
general terms then it wouldn't be dependent on sre anymore.
msg66204 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-04 12:46
BTW, the regression for not executing packages was intented. See #2751.
msg66215 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-04 15:30
Well, that's unfortunate. I found it very useful
msg66218 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-04 17:05
I've committed the reST docs. Bob, do you want to have a look?
msg66221 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-04 17:56
They look good, but is there an easy way to look at them post-formatting
or do I have to install the sphinx toolchain myself?

I moved the command-line stuff to json.tool to get around the package
problem.
msg66223 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-04 18:00
On Sun, May 4, 2008 at 12:56 PM, Bob Ippolito <report@bugs.python.org> wrote:
>
>  Bob Ippolito <bob@redivi.com> added the comment:
>
>  They look good, but is there an easy way to look at them post-formatting
>  or do I have to install the sphinx toolchain myself?

in the Doc directory, run make html.

>  I moved the command-line stuff to json.tool to get around the package
>  problem.

Why not json.pp (for pretty-print)?
msg66224 (view) Author: Georg Brandl (georg.brandl) Date: 2008-05-04 18:02
Benjamin, if you want you can send me the rst file for review. I tried
to checkout the bzr branch, but cancelled it after waiting for 25 minutes.
msg66225 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-04 18:05
I don't think that makes sense, "tool" makes it pretty clear that it's
something you use from the command-line rather than a module to import
and call functions from where pp does not.

I'd also rather call it pprint than pp if that were the decision.. EIBTI.
msg66227 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-04 18:09
Georg, I'm attaching json.rst.

Bob, I personally would prefer pprint, but it's your choice.
msg66232 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-04 19:32
When we're ready, I'll merge this into the trunk and Py3k. (There are no
Py3k warnings on test, so it should only be a matter of running 2to3.)
msg66233 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-04 19:41
The ref leak and unit tests are passing on Windows, too. I'm going to
change the import of the C extension and then you can commit the bzr
branch into the trunk.

For 3.0 the C module probably needs some changes. I'll look into it once
the code is merged into the trunk.
msg66257 (view) Author: Philip Jenvey (pjenvey) Date: 2008-05-05 04:48
Bob, all of the simplejson tests have actually been passing on Jython 
trunk -- at least up until recently when you added a couple tests that 
utilize the 2.4 decimal module.

I can also import simplejson.scanner with a recent build of pypy, so it at 
least has those sre imports you're using.
msg66279 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-05 19:32
Please merge the bzr into the svn trunk as soon as possible. I'd like to
get it into the last alpha release.
msg66280 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-05 19:56
So there is one failing test because json.dumps() tacks on extraneous 
whitespace. When you run the file through reindent it strips out the 
whitespace from the docstring, causing doctest to fail.

Trying to fix it.
msg66282 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-05 20:22
r62734 has it in the trunk. I had to change a doctest to use repr() in 
order to get around the extraneous whitespace that pretty-printing spits 
out, but otherwise I only added a Misc/NEWS entry.
msg66283 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-05 20:23
I am leaving this issue open until 'json' is ported to 3.0 (and thus why I 
am assigning this to Christian).
msg66284 (view) Author: Georg Brandl (georg.brandl) Date: 2008-05-05 20:54
Fixed up the docs in r62736.
msg66312 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-06 13:52
The Python 3.0 port is going to be tricky. Can somebody with more
knowledge about the code please annotate which methods accept/return
bytes and/or unicode?
msg66315 (view) Author: Bob Ippolito (bob.ippolito) Date: 2008-05-06 14:52
loads will take unicode or str. if it's str then it assumes utf-8,
otherwise the explicitly specified encoding. All of the string instances
generated by loads will be unicode objects (some of them may be str
objects if they're all ASCII as an optimization, I'm not sure if I
implemented that or not).

dumps produces an ASCII str, but if you explicitly specify
ensure_ascii=False then it will return a unicode object.

obviously load and dump will be working on a file-like object so should
be dealing with bytes...

I'm not entirely sure whether semantically dumps should produce bytes or
str in py3k, I guess whatever the other text-based encodings do is
appropriate (e.g. base64, mime).
msg66331 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-06 20:13
Since dumps and loads deal with raw data they should accept/return
bytes, too.

I'm re-adding 2.6 as version again because I believe we should clean up
the API in 2.6 first. It's also a good chance to document how to port a
library to Python 2.6 and 3.0. *wink*
msg66380 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-08 00:08
Command to merge json into 3.0:

svnmerge.py unblock -r62734,62736,62748,62769; svnmerge.py merge --force
-r62734,62736,62748,62769
msg66381 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-08 00:18
On Wed, May 7, 2008 at 7:08 PM, Christian Heimes <report@bugs.python.org> wrote:
>
>  Christian Heimes <lists@cheimes.de> added the comment:
>
>  Command to merge json into 3.0:
>
>  svnmerge.py unblock -r62734,62736,62748,62769; svnmerge.py merge --force
>  -r62734,62736,62748,62769

Why is the --force needed?
msg66383 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-08 00:22
Because I haven't committed the result of svnmerge.py unblock yet.
svnmerge.py refuses to work on a sandbox with uncommitted changes.

2to3:

./python Tools/scripts/2to3 -w Lib/json/
./python Tools/scripts/2to3 -w -d Lib/json/
msg66385 (view) Author: Christian Heimes (christian.heimes) Date: 2008-05-08 01:31
I got the JSON module working under Python 3.0. I'm still not happy with
the mixing of bytes and unicode, though.

The patch contains additional changes to "svnmerge.py unblock
-r62734,62736,62748,62769; svnmerge.py merge --force
-r62734,62736,62748,62769"
msg66391 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-08 02:18
When you've merged it, I'll alter the 3.0 docs.
msg66905 (view) Author: Brett Cannon (brett.cannon) Date: 2008-05-16 05:00
Can this issue be closed?
msg66970 (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-05-16 22:35
Let's see:

1. Fix up and add to trunk. Check!
2. Convert docs to reST. Check!
3. Port to 3.0. Check!
4. Fix docs in 3.0. Check!

Yes, we can close this.
History
Date User Action Args
2008-05-16 22:35:23benjamin.petersonsetstatus: open -> closed
resolution: accepted
messages: + msg66970
2008-05-16 05:00:25brett.cannonsetmessages: + msg66905
2008-05-08 02:18:25benjamin.petersonsetmessages: + msg66391
2008-05-08 01:32:00christian.heimessetfiles: + json_py3k.patch
messages: + msg66385
2008-05-08 00:22:33christian.heimessetmessages: + msg66383
2008-05-08 00:18:52benjamin.petersonsetmessages: + msg66381
2008-05-08 00:08:23christian.heimessetmessages: + msg66380
2008-05-06 20:13:58christian.heimessetmessages: + msg66331
versions: + Python 2.6
2008-05-06 14:52:23bob.ippolitosetmessages: + msg66315
2008-05-06 13:52:03christian.heimessetmessages: + msg66312
2008-05-05 20:54:16georg.brandlsetmessages: + msg66284
2008-05-05 20:23:30brett.cannonsetversions: - Python 2.6
2008-05-05 20:23:22brett.cannonsetassignee: benjamin.peterson -> christian.heimes
messages: + msg66283
2008-05-05 20:22:29brett.cannonsetmessages: + msg66282
2008-05-05 19:56:23brett.cannonsetmessages: + msg66280
2008-05-05 19:32:01christian.heimessetmessages: + msg66279
2008-05-05 04:48:26pjenveysetnosy: + pjenvey
messages: + msg66257
2008-05-04 19:41:36christian.heimessetmessages: + msg66233
2008-05-04 19:32:03benjamin.petersonsetassignee: benjamin.peterson
messages: + msg66232
2008-05-04 18:09:03benjamin.petersonsetfiles: + json.rst
messages: + msg66227
2008-05-04 18:05:25bob.ippolitosetmessages: + msg66225
2008-05-04 18:02:45georg.brandlsetnosy: + georg.brandl
messages: + msg66224
2008-05-04 18:00:09benjamin.petersonsetmessages: + msg66223
2008-05-04 17:56:42bob.ippolitosetmessages: + msg66221
2008-05-04 17:05:12benjamin.petersonsetmessages: + msg66218
2008-05-04 15:30:08bob.ippolitosetmessages: + msg66215
2008-05-04 12:46:40benjamin.petersonsetmessages: + msg66204
2008-05-04 08:04:57bob.ippolitosetmessages: + msg66197
2008-05-04 07:50:31brett.cannonsetmessages: + msg66195
2008-05-04 07:09:22bob.ippolitosetmessages: + msg66194
2008-05-04 07:03:09brett.cannonsetmessages: + msg66193
2008-05-04 01:33:28benjamin.petersonsetmessages: + msg66186
2008-05-04 01:12:32bob.ippolitosetmessages: + msg66185
2008-05-03 22:52:03benjamin.petersonsetmessages: + msg66183
2008-05-03 22:51:20brett.cannonsetmessages: + msg66182
2008-05-03 22:24:18brett.cannonsetmessages: + msg66181
2008-05-03 22:20:49brett.cannonsetmessages: + msg66180
2008-05-03 22:19:09christian.heimessetnosy: + christian.heimes
messages: + msg66179
2008-05-03 22:15:05brett.cannonsetnosy: + brett.cannon
messages: + msg66178
2008-05-03 22:07:55brett.cannonsetpriority: critical
2008-05-03 22:06:24brett.cannonsetkeywords: + patch
2008-05-03 22:01:35benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg66177
2008-05-03 21:52:54bob.ippolitocreate