Recursion limit of pickle?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sat Feb 9 22:42:11 EST 2008


En Sat, 09 Feb 2008 09:49:46 -0200, Victor Lin <Bornstub at gmail.com>  
escribi�:

> I encounter a problem with pickle.
> I download a html from:
>
> http://www.amazon.com/Magellan-Maestro-4040-Widescreen-Navigator/dp/B000NMKHW6/ref=sr_1_2?ie=UTF8&s=electronics&qid=1202541889&sr=1-2
>
> and parse it with BeautifulSoup.
> This page is very huge.
> When I use pickle to dump it, a RuntimeError: maximum recursion depth
> exceeded occur.

BeautifulSoup objects usually aren't pickleable, independently of your  
recursion error.

py> import pickle
py> import BeautifulSoup
py> soup = BeautifulSoup.BeautifulSoup("<html><body>Hello, world!</html>")
py> print pickle.dumps(soup)
Traceback (most recent call last):
...
TypeError: 'NoneType' object is not callable
py>

Why do you want to pickle it? Store the downloaded page instead, and  
rebuild the BeautifulSoup object later when needed.

-- 
Gabriel Genellina




More information about the Python-list mailing list