
June 19, 2008
4:25 a.m.
Marcel Hellkamp wrote:
This script crashes with a segmentation fault :/
import cPickle [...] tree = lxml.html.fromstring(html)
cf = open('test.pcl', 'w') cPickle.dump(tree, cf, -1) cf.close()
cf = open('test.pcl', 'r') pickled_tree = cPickle.load(cf) cf.close()
Yes, you can't pickle Elements in lxml.etree. This feature is currently only available in lxml.objectify, where Elements behave a lot more like Python objects. I think it makes a little less sense in lxml.etree where you'd have to keep some more state about the Element classes used inside the tree. I'm not sure how valuable this is in lxml.html. Could you describe your use case a little? Stefan