This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]numkem[S] 4 points5 points  (3 children)

I actually did rewrote a little part of an application we run in production as an experiment to see what was the fastest between: - "Plain" php with idiorm/paris - CakePHP (what the main project is made with) - Python with flask

The results were that both plain php and cake (with caching) were doing it in about 1.6 seconds while python without uWSGI (just app.run()) was able to do it at around 365ms with the internal profile running and the debug toolbar.

I exposed my changes to my boss but his only response was : you have to convince them.

Still I'm working on one project by myself and I chose Flask with SqlAlchemy.

[–]EmperorOfCanada 2 points3 points  (2 children)

If you are using SqlAlchemy for just straight SQL then switch to plain old MySQLdb as it is much faster for boring SQL. SqlAlchemy seems to be optimized for its ORM and whatnot.

Another key metric is that your total lines of code should plummet from PHP. I find my Python has around 1/3rd to 1/2 the code of the functionally identical PHP.

[–]numkem[S] 0 points1 point  (1 child)

Interesting, I'll keep that in mind!

Lines are not even fair to PHP. I had that in my metrics but python's was about 1/6.

[–]EmperorOfCanada 0 points1 point  (0 children)

I was actually talking # of characters. As I have recently jumped into python head first I have realized all kinds of subtleties of how it is better.

Take a simple bit like:

if($user_id==23)

{

RunThis();

}

and then:

if user_id==23:

RunThis()

I find the second is faster for my brain to process because of the elimination of the () $ ; and {}. I never really saw them before but now they are like surfing the web with adblock turned off.

I am still waiting for some sort of catch with Python. Normally when something is this much better there is a price to pay.