cpython and web2py

171 views
Skip to first unread message

Ron Chatterjee

unread,
May 15, 2017, 9:40:09 PM5/15/17
to web2py-users
Have anyone ever tried to put a wrapper around the default.py with cpython to make it faster?

Ron Chatterjee

unread,
May 15, 2017, 10:16:03 PM5/15/17
to web2py-users
Actually, I am referring to cython. Not cpython.

Have anyone ever tried to put a cython wrapper into default.py?

Joe Barnhart

unread,
May 18, 2017, 4:46:31 AM5/18/17
to web2py-users
"Make it faster" is a nice goal, but it has many different components, and just compiling everything with cython is not an easy way out.

The path to take, like with any software project, is to implement the function that you need first. If, and only if, there is a performance problem, you carefully profile the system to find out exactly where the problem lies. Then you determine the best way to fix the problem.

I'll give you a peek in the back of the book -- born from 40+ years of programming experience. The problem is never where you thought it would be.

-- Joe

Ron Chatterjee

unread,
May 28, 2017, 11:50:15 AM5/28/17
to web2py-users
I understand that. No one is disputing better coding better performance. But the question is:

Cython wrapper (

Default. Py

)
Is it possible. If so how?

Joe Barnhart

unread,
Jun 17, 2017, 6:05:36 PM6/17/17
to web2py-users
No.

Ron Chatterjee

unread,
Jun 18, 2017, 6:27:19 PM6/18/17
to web2py-users
Have anyone tried this? Wondering if this is a way to gain some speed.

https://micropyramid.com/blog/running-django-with-pypy-to-boost-performance/

Joe Barnhart

unread,
Jun 25, 2017, 2:05:22 PM6/25/17
to web2py-users
It's hard to take these questions seriously when you haven't described your speed problem.  How is your website performing, and what are the bottlenecks you've found?

Yes, many people, including myself, have experimented with pypy and web2py.  If you're observant, you'll notice there are many messages on this forum, spanning years, which discuss web2py running on pypy.  Like cython, it is not a panacea.

Without sounding repetitive, there are many techniques for speeding up web2py.  Different techniques are employed for different problems.  There is no single "magic bullet" which just speeds up all web2py websites for all occasions.

-- Joe

Ron Chatterjee

unread,
Jun 25, 2017, 3:10:56 PM6/25/17
to web2py-users
Ok. I buy that.

Speed is always a plus.

Whats are the calls to run web2py with pypy? Can you share a link or an example? I cant seem to find that in the book.

Joe Barnhart

unread,
Jun 27, 2017, 10:50:23 PM6/27/17
to web2py-users
My experiments are all pretty old.  Too old to be useful.

Currently I have commercial websites using web2py and I don't need to do anything remarkable to make it faster.  I just used good design techniques and didn't do "premature optimization."  I'm now re-writing a Rails, site, a Java site, and an older web2py site into a combined site that will do all of the above.  My database is MySql and has about 50 tables, with 20 to 100 columns in each.  My largest table has about 3M rows in it.  I expect 30M when I'm done.

I chose indexes carefully and I used "modules" (i.e. compiled python) for most of the model/controller details.  The beta site beats the pants off the sites it is replacing.  No pypy needed.  No cython either.

If you're looking at platform "benchmarks" to make a decision of what is fast enough, just don't do that.  The benchmarks I looked at turned out to be worse than useless in practice.  Most benchmarks pare down the task into something small and atomic that can be done by every platform.  Which means if you're using the services of a full-service platform like web2py the benchmark is already slanted against you.  It will compare the platforms assuming you are not using DAL, templating, routing, and all of the other feature that make web2py useful.  Basically they just make every app look like "hello world" for web servers.

The only way to compare a platform is to use a workload like the one you will deploy.  Mine is VERY HEAVY on database usage so the SQL database dominates the page load time in most cases.  I also use some heavy Javascript libraries (like Datatables.net) which affects load times.  The speed problems are never where you think they'll be.  And clever caching and other techniques can fix just about anything.

-- Joe
Reply all
Reply to author
Forward
0 new messages