jsaone
                Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
| Entrambe le parti precedenti la revisioneRevisione precedenteProssima revisione | Revisione precedente | ||
| jsaone [2013/12/14 14:39] – pietro | jsaone [2019/02/05 18:16] (versione attuale) – on github pietro | ||
|---|---|---|---|
| Linea 1: | Linea 1: | ||
| - | ======  | + | {{:jsaone: | 
| - | This is a tiny wrapper around the standard  | + | {{: | 
| + | |||
| + | {{: | ||
| + | |||
| + | ====== What is jsaone? ====== | ||
| + | |||
| + | This is a tiny wrapper around the json module in the Python standard  | ||
| This can be useful for | This can be useful for | ||
|   * parsing json streams without waiting for the end of the transmission, |   * parsing json streams without waiting for the end of the transmission, | ||
| * parsing very big json objects without wasting RAM for the json representation itself. | * parsing very big json objects without wasting RAM for the json representation itself. | ||
| + | |||
| + | It is an alternative to [[https:// | ||
| === Efficiency === | === Efficiency === | ||
| Linea 13: | Linea 21: | ||
| totalling 174 MB: | totalling 174 MB: | ||
| - | ^ Parser  | + | ^ Parser  | 
| - | | standard (non-incremental) json |    | + | | standard (non-incremental) json |    9.511      | 
| - | | cythonized jsaone  | + | | cythonized jsaone  | 
| - | | ijson (with yajl2 backend)  | + | | ijson (with yajl2 backend)  | 
| - | | pure python jsaone  | + | | pure python jsaone  | 
| Those results were obtained with the script " | Those results were obtained with the script " | ||
| - | Clearly those numbers are affected by the speed of the CPU and of the medium. | + | Clearly those numbers are affected by the speed of the CPU and of the medium/stream. | 
| - | In general  | + | In particular, since the test was made on a file from a local hard disk, the | 
| - | fastest will be the standard json compared to incremental ones (including | + | bottleneck was clearly  | 
| - | jsaone). | + | parsers  | 
| + | jsaone should even outperform  | ||
| + | only after the entire stream is received. | ||
| === Why " | === Why " | ||
| Linea 35: | Linea 45: | ||
|   * [[http:// |   * [[http:// | ||
| - |   * for efficiency: [[http:// | + |   * for speedup: [[http:// | 
| + | |||
| + | === Installing === | ||
| + | |||
| + | - If you use Debian or a derivative (such as Ubuntu or Mint), you can simply use the packages provided above. | ||
| + | - **jsaone** is on pypi, so you can install it with //pip install jsaone// | ||
| + |   - you can extract/ | ||
| + | |||
| + | python3 setup.py build_ext --inplace | ||
| + | |||
| + | (replace " | ||
| + | |||
| + | |||
| + | === Usage === | ||
| + | |||
| + | |||
| + | import jsaone | ||
| + |   with open('/ | ||
| + | gen = jsaone.load(f) | ||
| + | for key, val in gen: | ||
| + | ... | ||
| + | |||
| + | === Development === | ||
| + | |||
| + | You can browse the git repo [[https:// | ||
| + |   git clone https:// | ||
| + | |||
| + | For bugs and enhancements, | ||
| + | |||
| + | Jsaone should be able to parse any compliant json string... so if you find one on which it fails, please let me know! | ||
| === License === | === License === | ||
| - | Released under the GPL 3. | + | Released under the GPL 3. Feel free to contact me if this is a problem for you (and GPL 2 is not). | 
jsaone.1387031980.txt.gz · Ultima modifica:  da pietro
                
                