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

  • SEARCH
  • Home
  • 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 3444500
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:55:23+00:00 2026-05-18T08:55:23+00:00

So I have a big project with many modules in it, and I want

  • 0

So I have a big project with many modules in it, and I want to run some profiling on it. I have a profile module that basically just provides a decorator that I can add to a function to profile it when it’s called.

The problem is, I’ll have to import that module into the dozens of modules that I have. This is fine I guess, but I can’t push the code with the profiling modules imported or the decorator on the functions to version control. This means every time I import/export, I have to add/remove all my profiling code.

Is there any kind of system to manage this adding/removing of profiling code without manually importing/deleting the modules in every module of my project? We use mercurial, but I can’t really mess with mercurial settings or make a branch.

  • 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-18T08:55:24+00:00Added an answer on May 18, 2026 at 8:55 am

    You could create your profiling module such that it imports your other modules and annotates their functions:

    # these are the modules you want to profile
    import foo
    import huh
    
    # This is a profiling function
    # yours would do something smarter
    def profile(f):
        def gotcha(*args, **kwds):
            print "before"
            result = f(*args, **kwds)
            print "after"
            return result
        return gotcha
    
    # these are the functions in those modules that you
    # want to profile.  Each one is patched here instead
    # of decorated there.
    foo.bar = profile(foo.bar)
    huh.baz = profile(huh.baz)
    huh.hmm = profile(huh.hmm)
    

    This way you don’t have to modify those modules, but if you choose to import this profiling module anywhere at runtime, it will “patch” all the other modules as you’d like

    You should be able to decorate class methods similarly.

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

Sidebar

Related Questions

I have a big red5 project and it seems that at some point a
I have a big project that was first created in Borland C++ 6. We're
I have a big load of documents, text-files, that I want to search for
We currently have a big Maven 2 project that is rather a collection of
We have a pretty big ASP.NET WebForm (web application) project with a lot of
We have a git project which has quite a big history. Specifically, early in
I have big issue with url-rewriting for IIS 7.0. I've written simple module for
How would you maintain the legacy applications that: Has no unit tests have big
I have a project right now that straddles the line on framework and pluggable
We are planning on restructuring a complex project with many modules/pieces, what ever you

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.