From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Julian Scheid Newsgroups: gmane.emacs.devel Subject: Fast JSON codec based on YAJL Date: Tue, 15 Jan 2013 01:36:04 +0100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1358210179 14425 80.91.229.3 (15 Jan 2013 00:36:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jan 2013 00:36:19 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jan 15 01:36:37 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TuuW1-000842-9N for ged-emacs-devel@m.gmane.org; Tue, 15 Jan 2013 01:36:33 +0100 Original-Received: from localhost ([::1]:54521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuuVk-0008R1-Vu for ged-emacs-devel@m.gmane.org; Mon, 14 Jan 2013 19:36:16 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuuVg-0008Ql-6p for emacs-devel@gnu.org; Mon, 14 Jan 2013 19:36:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuuVd-0004qu-Ck for emacs-devel@gnu.org; Mon, 14 Jan 2013 19:36:12 -0500 Original-Received: from mail-bk0-f48.google.com ([209.85.214.48]:50537) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuuVd-0004qo-6I for emacs-devel@gnu.org; Mon, 14 Jan 2013 19:36:09 -0500 Original-Received: by mail-bk0-f48.google.com with SMTP id jc3so2327194bkc.35 for ; Mon, 14 Jan 2013 16:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:mime-version :content-type; bh=i3LXsW7eySGdxCTZAjBC+u+iIu3BnHu6JtRlfCB057s=; b=Qt0VmJQJgv1j1fQrWbF+gl5SlHH/HS8pw3DXwu1G0tsAfttZdGM62ouHlrG5iQhkJr OcIW4SqBPau8oeer5dPL4HRNrgdNZ9ueGDERTxHMA/lZkV5Q+WQVBDiRvYYeNcPNWtbf veoaXTtXjV2+MsjrjGkwQdGjcVzvMfKeoii0osSDx4UZ5hFjex7omWVPcnkKfU10ZxJ7 er+boAZ8V7gaWhtf3Ab37V3z5GabyVVbPrc6BjiM9mLoP629vGmQIKkO2BoKsbWdTMYD jB8m9pCsaI1ATXUxbWvS6vvX85hvuH1dGn8OhfVTobaqbWhhlOuFdd+eXW57tUbxDS1E ln8w== X-Received: by 10.204.147.7 with SMTP id j7mr40681071bkv.125.1358210167878; Mon, 14 Jan 2013 16:36:07 -0800 (PST) Original-Received: from macbook.local (p5DCB7903.dip.t-dialin.net. [93.203.121.3]) by mx.google.com with ESMTPS id i20sm11386765bkw.5.2013.01.14.16.36.05 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 14 Jan 2013 16:36:06 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.214.48 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:156360 Archived-At: Hi, I'm getting close to finishing a first version of an interface to YAJL, "a small event-driven (SAX-style) JSON parser written in ANSI C, and a small validating JSON generator." See http://lloyd.github.com/yajl/ I've started working on this interface because json.el proves to be a bottleneck in another project of mine. A few unscientific benchmarks suggest that YAJL (via my interface) is roughly 5 to 25 times as fast as byte-compiled json.el, on average about an order of magnitude faster. Memory usage is about on par. With a few minor exceptions it's fully compatible to json.el and can be used as a drop-in replacement in most situations. [*] The interface also exposes a number of useful YAJL features not found in json.el, such as optional pretty-printing. It comes with a comprehensive ERT-based unit test suite, a small stress-test and benchmarking suite, full TexInfo documentation, and the usual detection code and switches for the configure script. I've looked at a number of JSON libraries and chose YAJL mainly because it's mature, clean and fast, and its event-driven architecture means a redundant document tree won't have to be kept in memory. YAJL is available in most major package repositories such as Debian, Red Hat, Arch Linux, and MacPorts. Is there interest in adding this interface to Emacs mainline? If so, I'd polish it a bit more and send over my code for review soon. As for the legal side, YAJL (the underlying library, not my interface) uses the ISC license but is only linked against. The interface itself doesn't include any ISC-licensed code, or any third-party code for that matter. I'd be happy to sign over copyright. Julian [*] The minor incompatibilities boil down to the fact that json.el can emit invalid JSON in some cases when YAJL refuses to do so. Example: (json-encode '((1 . 1))) will yield invalid JSON output. json.el also has issues with characters on the astral plane and some to do with NaN and Inf, which YAJL handles slightly different (and closer to the JSON specification.)