I think we learned a long time ago that though codegen is one path to speedy code, it is not the only path.<p>The thriftpy module dynamically generates a Python module that is based on parsing the thrift schema. That happens once: at module import time. After that, Python has cached the module in sys.modules and it doesn&#x27;t need to be evaluated again during the program&#x27;s runtime.<p>The module contains efficient Python classes that are Python bytecode just the same way &quot;compiled&quot; classes would be. But, thriftpy has Cython implementation of Thrift protocols and transports that compile down to C, not Python bytecode. Thus, the thriftpy impl&#x27;s are not only more dynamic and less cumbersome than the codegen alternative, but they are also faster.<p>In the Python community, we prefer to take other approaches to achieve execution speed.<p>Dynamically generating a Python module is not &quot;metaprogramming&quot;. It is not black magic. You can generate a module yourself simply by instantiating a Python module type. Hooking the import statement is an officially supported part of the language, and done by many libraries.<p>This may all seem very worrying to a C++ or Java programmer, but in the Python community we have been doing dynamism with execution  speed for about 10 years now, and we haven&#x27;t regretted any of the results!