I can provide the implementation if you can come up with a set of suitable tests. It should be possible to use cython.inline() for that (if Cython is installed and Py>=2.7). It's a bit underdocumented, you might have to read the source code. But it allows you to write the code in Cython and get it compiled from a Python string at runtime. The build setup should be available via lxml.get_include() and you can define the linker flags via distutils arguments.
I can provide the implementation if you can come up with a set of suitable tests. It should be possible to use cython.inline() for that (if Cython is installed and Py>=2.7). It's a bit underdocumented, you might have to read the source code. But it allows you to write the code in Cython and get it compiled from a Python string at runtime. The build setup should be available via lxml.get_include() and you can define the linker flags via distutils arguments.
http:// docs.cython. org/en/ latest/ src/reference/ compilation. html#compiling- with-cython- inline
API function: adopt_external_ document( capsule) -> ElementTree xmlFreeDoc"
Capsule name: (const char*) "libxml2:xmlDoc"
Fast capsule context: (const char*) "destructor: