xml - Using cElementTree in python 3 -
celementtree
fast, c implementation of xml api elementtree
. in python 2 load explicitly (aliasing elementtree
), in the python 3 docs read this:
changed in version 3.3: module use fast implementation whenever available. xml.etree.celementtree module deprecated.
indeed, xml.etree.celementtree.py
imports xml.etree.elementtree
. question: how access "fast implementation"? how tell if it's "available", , if reason it's not distributed python?
introspection on elementtree
in program suggests i'm getting python version. in elementtree.py
, didn't spot hooks c version. when , how come play? elementtree
documentation offered no clues, , neither did quick search on google , stackoverflow.
from "what's new in python 3.3" docs:
the
xml.etree.elementtree
module imports c accelerator default; there no longer need explicitly import xml.etree.celementtree (this module stays backwards compatibility, deprecated). in addition, iter family of methods of element has been optimized (rewritten in c). module’s documentation has been improved added examples , more detailed reference.
while may though isn't happening import takes place silently. find section of code in elelementtree.py
reads
# import c accelerators try: # element, subelement, parseerror, treebuilder, xmlparser _elementtree import * except importerror: pass else: # overwrite 'elementtree.parse' , 'iterparse' use c xmlparser class elementtree(elementtree): ...
there doesn't seem easy way verify c module being imported, think can take it is. if worried (and wouldn't be) can patch print
in there check.
Comments
Post a Comment