推荐学习书目
› 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
wohenfuyou
V2EX  ›  Python

各位彦祖, Python 用哪个加载 xml 文件比较快

  •  
  •   wohenfuyou · May 12, 2021 · 2605 views
    This topic created in 1964 days ago, the information mentioned may be changed or developed.

    用了 xml.dom.minidom,加载个 100M 的 XM 的文件用了 60s,好慢

    6 replies  •  2021-05-13 08:48:03 +08:00
    no1xsyzy
        1
    no1xsyzy  
       May 12, 2021   ❤️ 1
    https://lxml.de/performance.html

    目前通常认为是 lxml 最快
    wellsc
        2
    wellsc  
       May 12, 2021
    换语言
    imn1
        3
    imn1  
       May 12, 2021   ❤️ 2
    100M 的应该什么语言都用流式解析吧,整体加载 DOM 太大了,非常耗资源
    找 xml parser 相关的库,例如 sax
    abersheeran
        4
    abersheeran  
       May 12, 2021 via Android
    @no1xsyzy 提到这玩意儿。我想起来以前写一个页面解析的时候,用 docker 跑的,阿里云 Serverless 上 lxml 怎么都解析不出来,我本机次次跑都没问题,最后还是换了 html.parser 。
    ALLROBOT
        5
    ALLROBOT  
       May 13, 2021
    用 C/C++最快

    python 执行速度比它们慢多了
    wohenfuyou
        6
    wohenfuyou  
    OP
       May 13, 2021
    改用 c++ tinyxml2 了 就 2s 钟,差距也太大了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   838 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 22:27 · PVG 06:27 · LAX 15:27 · JFK 18:27
    ♥ Do have faith in what you're doing.