Is code interpreted at every call in Web2Py?

If so, What is the advantage ? (sure it will avoid restarting webserver). But isn't it a perfomance bottleneck? For production, is it possible to make web2py run directly from bytecode skipping interpreting stage (Caching) (except for the first request) ?

Answers


In web2py, by default, all code in models, views and controllers (not web2py code, not code in modules imported by your models, views, controllers) is interpreted at every request. This allows to use a third party web server (for example apache) and still be able to see changes in your code reflected immediately without restart. PHP works in the same way. The performance penalty is negligible because the time to parse your code is less than the time to execute your code.

Anyway, in the admin interface there is a "compile" button that will bytecode compile your code and collapse the view hierarchy (extended and included views) into a single file per action and remove the performance penalty. It also allows you to distribute your code bytecode compiled without giving away the source. The license allows it.


I don't know web2py particularly, but it runs via WSGI like most other Python frameworks. This means that code is only interpreted when the process starts, and is otherwise kept in memory. Processes are dynamically started and killed by the web server itself, but usually last for multiple requests.

In any case, the Python interpreter usually creates a byte-code file, .pyc, when code is first read. This works in a webserver environment just as it does anywhere else.

Finally, however, it is generally considered that code parsing is not particularly a bottleneck - the conversion to bytecode is pretty quick. In a web application, your bottleneck is almost certainly elsewhere (probably in the connection to the database).


Need Your Help

Node + Express Session Expiration?

javascript node.js session express

I have an app in express and I have a login form. I need sessions to last for 1 month do I set maxAge to a month in milliseconds.

Dropdown change not calling method asp.net mvc jquery

c# jquery asp.net asp.net-mvc asp.net-mvc-4

first off I have used this thread to get where I am now but am having difficulty with my situation. ASP.NET MVC 3 DropDownList selectedindexchanged