marrow / WebCore

WebCore, the super tiny and blazingly fast modular Python web nanoframework.
MIT License
96 stars 9 forks source link

Callback optimization. #159

Closed amcgregor closed 3 years ago

amcgregor commented 8 years ago

All of the Extension callback sites are list iterators calling functions. That's a lot of stack allocation and deallocation. This is no big deal under Pypy's JIT; it'd pretty quickly figure out the game. CPython on the other hand won't. Each callback is provided the same arguments, excepting one case which is more like a reduce call.

The process would be roughly:

Huzzah, function inlining to remove call frame / stack overhead on those repeated calls.

amcgregor commented 3 years ago

Impractical to implement; for this type of optimization just run your application under the Pypy runtime, utilizing its JIT compilation functionality. The loops in operation to implement current callback functionality would be rapidly optimized.