On Tue, Jan 15, 2013 at 3:26 AM, Stefan Monnier wrote: > You mean that json.elc is only 5 to 25 times slower than > a C implementation? I actually expected significantly worse. > Both share quite a few code paths actually, for example number-to-string conversion (and vice versa) and multibyte handling. I wrote the code a little while ago but IIRC data conversion between Emacs-land and native land accounts for a non-negligible share of the runtime, and of course the same goes for building Emacs data structures from parsed data. (It doesn't help that with JSON, you don't know how big an array or map will be until you're finished parsing it.) Also, although performance is my primary objective, I didn't pick the C library on that aspect alone. For example, libjson bills itself as a "JSON reader and writer which is super-effiecient [sic] and usually runs circles around other JSON libraries." But it doesn't support streaming and thus would add a significant memory overhead for large documents, and also it's not nearly as portable. I did spend some time making sure that the interface performs well and there are no obvious low-hanging-fruit-type optimizations left, but any help with making it even faster is welcome! I think that an order of magnitude is a good start though, it certainly takes my other app from "painfully slow" to "perfectly usable".