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

如何用python实现linked list的serialization(有recursion的data structure如何序列化)

  •  
  •   Fteng328 ·
    fteng328 · Jul 25, 2012 · 5068 views
    This topic created in 5174 days ago, the information mentioned may be changed or developed.
    小弟最近需要从数据库里建一个twitter follower network.
    研究了一下最后打算用linked list. 为了以后方便lookup以及调用就直接用pickle把这个data structure序列化到一个独立的文本,

    但是pickle到70个node以上以后会遇到
    RuntimeError: maximum recursion depth exceeded.

    在网上查了一下是因为linked list 有node指向自己所以会导致serialization的时候产生recursion.

    接下来用Jsonpickle试了一下,还是会有RuntimeError: maximum recursion depth exceeded while calling a Python object


    有点迷茫,不知接下来应该怎么处理这个问题,各位有什么建议吗?第一次发帖求助 感谢
    3 replies  •  1970-01-01 08:00:00 +08:00
    daqing
        1
    daqing  
       Jul 25, 2012
    最简单的办法:自己遍历linked list,生成一个JSON数组。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   847 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:47 · PVG 04:47 · LAX 13:47 · JFK 16:47
    ♥ Do have faith in what you're doing.