Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why can I reuse XSLT stylesheets in other threads?

reuse stylesheets threads XSLT
0
10 Posted

Why can I reuse XSLT stylesheets in other threads?

0

Since lxml 2.0, you can. However, it is a lot more efficient to use stylesheets in the thread that created them. This is due to some interfering optimisations in libxslt and lxml.etree. It is therefore a good idea to cache them in thread local storage (see Python’s threading module). lxml cannot easily do this for you, as it cannot know when to discard them from such a cache. If you use very complex stylesheets or create stylesheets programmatically, you should do so in the main thread, and then copy them into the thread cache using the copy module from the standard library.

0

Since lxml 2.0, you can. However, it is a lot more efficient to use stylesheets in the thread that created them. This is due to some interfering optimisations in libxslt and lxml.etree. It is therefore a good idea to cache them in thread local storage (see Python’s threading module). lxml cannot easily do this for you, as it cannot know when to discard them from such a cache. If you use very complex stylesheets or create stylesheets programmatically, you should do so in the main thread, and then copy them into the thread cache using the copy module from the standard library.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123