Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 197611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:52:04+00:00 2026-05-11T16:52:04+00:00

I’m currently trying to optimize my website, which is run on the Google App

  • 0

I’m currently trying to optimize my website, which is run on the Google App Engine. It’s not an easy task, because I’m not using any powerful tool.

Does anyone have experience in optimizing Python code for this purpose?
Have you find a good Python profiler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:52:04+00:00Added an answer on May 11, 2026 at 4:52 pm

    I have found Gprof2Dot extremely useful. The output of the profiling modules I’ve tried as pretty unintuitive to interpret.

    Gprof2Dot turns the cProfile output into a pretty looking graph, with the slowest chain(?) highlighted, and a bit of information on each function (function name, percentage of time spend on this function, and number of calls).

    An example graph (1429x1896px)

    I’ve not done much with the App Engine, but when profiling non-webapp scripts, I tend to profile the script that runs all the unittests, which may not be very accurate to real-world situations

    One (better?) method would be to have a script that does a fake WSGI request, then profile that.

    WSGI is really simple protocol, it’s basically a function that takes two arguments, one with request info and the second with a callback function (which is used for setting headers, among other things). Perhaps something like the following (which is possible-working pseudo code)…

    class IndexHandler(webapp.RequestHandler):
        """Your site"""
        def get(self):
            self.response.out.write("hi")
    
    if __name__ == '__main__':
        application = webapp.WSGIApplication([
            ('.*', IndexHandler),
        ], debug=True)
    
        # Start fake-request/profiling bit
        urls = [
            "/",
            "/blog/view/hello",
            "/admin/post/edit/hello",
            "/makeanerror404",
            "/makeanerror500"
        ]
    
        def fake_wsgi_callback(response, headers):
            """Prints heads to stdout"""
            print("\n".join(["%s: %s" % (n, v) for n, v in headers]))
            print("\n")
    
        for request_url in urls:
            html = application({
            'REQUEST_METHOD': 'GET',
            'PATH_INFO': request_url},
            fake_wsgi_callback
            )
            print html
    

    Actually, the App Engine documentation explains a better way of profiling your application:

    From http://code.google.com/appengine/kb/commontasks.html#profiling:

    To profile your application’s performance, first rename your application’s main() function to real_main(). Then, add a new main function to your application, named profile_main() such as the one below:

    def profile_main():
        # This is the main function for profiling 
        # We've renamed our original main() above to real_main()
        import cProfile, pstats
        prof = cProfile.Profile()
        prof = prof.runctx("real_main()", globals(), locals())
        print "<pre>"
        stats = pstats.Stats(prof)
        stats.sort_stats("time")  # Or cumulative
        stats.print_stats(80)  # 80 = how many to print
        # The rest is optional.
        # stats.print_callees()
        # stats.print_callers()
        print "</pre>"
    

    […]

    To enable the profiling with your application, set main = profile_main. To run your application as normal, simply set main = real_main.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 144k
  • Answers 144k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Casting is much faster that most people seem to think… May 12, 2026 at 8:39 am
  • Editorial Team
    Editorial Team added an answer actually your site is hacked. it happened to me too.… May 12, 2026 at 8:39 am
  • Editorial Team
    Editorial Team added an answer As Chris pointed, in PostgreSQL it's no problem - any… May 12, 2026 at 8:39 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.