推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
zhoudaiyu
V2EX  ›  Python

Python 哪个 json 库反序列化最快?

  •  
  •   zhoudaiyu ·
    PRO
    · Dec 28, 2020 via iPhone · 5083 views
    This topic created in 1963 days ago, the information mentioned may be changed or developed.

    测了一下 ujson 比自带 json 快了不少,但是还是满足不了接口速度的要求,有没有更快一点的库?只考虑反序列化

    15 replies    2021-01-01 12:01:05 +08:00
    codebigbang
        1
    codebigbang  
       Dec 28, 2020 via Android
    场景是否支持先把数据切块?
    zhoudaiyu
        2
    zhoudaiyu  
    OP
    PRO
       Dec 28, 2020 via iPhone
    @codebigbang 切片么就是
    NBNPC
        3
    NBNPC  
       Dec 28, 2020
    VYSE
        4
    VYSE  
       Dec 28, 2020
    只考虑反序列化: msgpack
    ClericPy
        5
    ClericPy  
       Dec 28, 2020
    cjson ojson

    不过有一些 by design 的坑自己得注意点... 记得还有个更快的, 但是不流行就懒得去搜了, 感兴趣可以随便搜搜 fastest python json
    ClericPy
        6
    ClericPy  
       Dec 28, 2020
    打错.. orjson...
    gainsurier
        7
    gainsurier  
       Dec 28, 2020
    考虑绝对性能的话,可以试试 simdjson 和 rapidjson 或者 yyjsonde c 接口封装。
    abersheeran
        8
    abersheeran  
       Dec 28, 2020
    讨论出结果了麻烦敲我一下,刚好也需要用到有性能需求的 JSON 模块。
    so1n
        9
    so1n  
       Dec 29, 2020
    目前只有 python 在用的话我是用 orjson 如果双端可以一起改的 则用 msgpack
    yingbo
        10
    yingbo  
       Dec 29, 2020
    用过 ujson,比标准库的快很多。楼上提到的别的没用过。
    momo1999
        11
    momo1999  
       Dec 29, 2020
    只用 ujson 替换过内置的
    nonduality
        12
    nonduality  
       Dec 29, 2020
    我也需要高速 JSon 模块,但在 Alpine Linux 下,因 orjson 是 rust 写的不方便编译,ujson 不能用 musl 库。

    不知有哪位高人能把 yyjson 封装成 python 模块,yyjson 是用 ansi C 写的,理论上能适应 Alpine Linux
    Arthur2e5
        14
    Arthur2e5  
       Dec 29, 2020
    > @nonduality ujson 不能用 musl 库。

    不该啊,这群人三年前不是还修过一个 alpine 崩溃的 bug ?
    https://github.com/ultrajson/ultrajson/pull/281

    有问题再开一个就是了。
    nonduality
        15
    nonduality  
       Jan 1, 2021
    @icyalala Good! 多谢!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   915 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 81ms · UTC 20:46 · PVG 04:46 · LAX 13:46 · JFK 16:46
    ♥ Do have faith in what you're doing.