How to make a copy of a python module at runtime?

You can always do tricks like importing a module then deleting it from sys.modules or trying to copy a module. However, Python already provides what you want in its Standard Library. import imp # Standard module to do such things you want to. # We can import any module including standard ones: os1=imp.load_module(‘os1’, *imp.find_module(‘os’)) # … Read more

PyEval_InitThreads in Python 3: How/when to call it? (the saga continues ad nauseam)

Your understanding is correct: invoking PyEval_InitThreads does, among other things, acquire the GIL. In a correctly written Python/C application, this is not an issue because the GIL will be unlocked in time, either automatically or manually. If the main thread goes on to run Python code, there is nothing special to do, because Python interpreter … Read more

Building lxml for Python 2.7 on Windows

I bet you’re not using VS 2008 for this 🙂 There’s def find_vcvarsall(version): function (guess what, it looks for vcvarsall.bat) in distutils with the following comment At first it tries to find the productdir of VS 2008 in the registry. If that fails it falls back to the VS90COMNTOOLS env var. If you’re not using … Read more