V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2020-12-28 20:40:15 +08:00 via iPhone · 4325 次点击
    这是一个创建于 1208 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    15 条回复    2021-01-01 12:01:05 +08:00
    codebigbang
        1
    codebigbang  
       2020-12-28 20:45:10 +08:00 via Android
    场景是否支持先把数据切块?
    zhoudaiyu
        2
    zhoudaiyu  
    OP
       2020-12-28 20:55:44 +08:00 via iPhone
    @codebigbang 切片么就是
    NBNPC
        3
    NBNPC  
       2020-12-28 21:03:15 +08:00
    VYSE
        4
    VYSE  
       2020-12-28 21:03:43 +08:00
    只考虑反序列化: msgpack
    ClericPy
        5
    ClericPy  
       2020-12-28 21:03:57 +08:00
    cjson ojson

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

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

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

    有问题再开一个就是了。
    nonduality
        15
    nonduality  
       2021-01-01 12:01:05 +08:00
    @icyalala Good! 多谢!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2800 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:07 · PVG 21:07 · LAX 06:07 · JFK 09:07
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.