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 6093023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:30:45+00:00 2026-05-23T12:30:45+00:00

i have two modules: moduleParent and moduleChild i’m doing something like this in moduleParent:

  • 0

i have two modules: moduleParent and moduleChild

i’m doing something like this in moduleParent:

import moduleChild

#a bunch of code

start = time.time()
moduleChild.childFunction()
finish = time.time()
print "calling child function takes:", finish-start, "total seconds"

#a bunch of code

i’m doing something like this in moduleChild:

def childFunction():
    start = time.time()
    #a bunch of code
    finish = time.time()
    print "child function says it takes:", finish-start, "total seconds"

the output looks like this:

calling child function takes: .24 total seconds
child function says it takes: 0.0 total seconds

so my question is, where are these .24 extra seconds coming from?

thank you for your expertise.

#

here is the actual code for “childFuntion”. it really shouldn’t take .24 seconds.

 def getResources(show, resourceName='', resourceType=''):
   '''
   get a list of resources with the given name

   @show: show name
   @resourceName: name of resource
   @resourceType: type of resource
   @return: list of resource dictionaries
   '''

   t1 = time.time()

   cmd = r'C:\tester.exe -cmdFile "C:\%s\info.txt" -user root -pwd root'%show
   cmd += " -cmd findResources -machineFormatted "

   if resourceName:
       cmd += '-name %s'%resourceName

   if resourceType:
       cmd += '_' + resourceType.replace(".", "_") + "_"

   proc=subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
   output = proc.stdout.read()
   output = output.strip()

   resourceData = output.split("\r\n")
   resourceData = resourceData[1:]

   resourceList = []
   for data in resourceData:
       resourceId, resourceName, resourceType = data.split("|")
       rTyp = "_" + resourceType.replace(".", "_") + "_"
       shot, assetName = resourceName.split(rTyp)
       resourceName = assetName
       path = '//projects/%s/scenes/%s/%s/%s'%(show, shot, resourceType.replace(".", "/"), assetName)
       resourceDict = {'id':resourceId, 'name':resourceName, 'type':resourceType, 'path':path }
       resourceList.append(resourceDict)

   t2 = time.time()
   print ("     ", t2 - t2, "seconds")


   return resourceList
  • 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-23T12:30:45+00:00Added an answer on May 23, 2026 at 12:30 pm

    Edit 2: I just noticed a typo in child function, you have t2 – t2 in the print statement

    ignore below:

    Calling the function itself has overhead (setting up stack space, saving local variables, returning, etc). The result suggests that your function is so trivial that setting up for a function call took longer than running the code itself.

    Edit: also, calling the timers as well as print ads overhead. Now that I think about it, calling print could account for a lot of that .24 seconds. IO is slow.

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

Sidebar

Related Questions

I have two modules like this (very very simplified): main.py: from window import *
In my code base I find that two modules have structures with the same
Consider this scenario: I have a project with two modules and one common module
I have two times, a start and a stop time, in the format of
I have two modules, default and mojo. After the initial bootstraping code which is
Suppose I have two modules: a.py: import b print __name__, __file__ b.py: print __name__,
Suppose we have two modules with cyclic dependencies: # a.py import b def f():
I have two python modules: a.py import b def hello(): print hello print a.py
suppose you have two modules like module Foo.A where foo = 42 and module
Assuming I have two Python modules and path_b is in the import path: #

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.