Python Forum
module functions and data references
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
module functions and data references
#6
Importing something let the Interpreter parse the whole file, translate it into bytecode and then the interpreter is executing the whole file.
In fact if you're using something like:
from util import foo
The whole file util is imported as module, which lives on the heap (i think so).
Only the the function foo is assigned to the name foo, but the function foo can access to everything inside the module util.
The name foo is just a reference to the function foo inside the module util.

If you delete foo the module util, it is not garbage collected, because all modules are cached. If you importing in many different modules the same module again and again, you'll get exactly the same version of the module.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
module functions and data references - by Skaperen - Jul-29-2017, 03:15 AM
RE: module functions and data references - by buran - Jul-29-2017, 05:07 AM
RE: module functions and data references - by DeaD_EyE - Jul-29-2017, 10:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  get data from 2 async functions korenron 0 1,259 Sep-22-2021, 08:39 AM
Last Post: korenron
  Environment seems to keep losing references spacedog 2 1,941 Apr-23-2021, 07:36 PM
Last Post: spacedog
  Taking serial data to perform key.press functions ausbollinger13 1 2,367 Sep-04-2020, 10:26 PM
Last Post: bowlofred
  module to store functions/variables and how to call them? mstichler 3 2,468 Jun-03-2020, 06:49 PM
Last Post: mstichler
  assignments of function references Skaperen 3 2,451 Aug-15-2019, 11:12 AM
Last Post: fishhook
  How to find functions or methods in a module? deepakdeshp 8 4,381 May-23-2019, 09:36 AM
Last Post: DeaD_EyE
  calling os functions not in module os Skaperen 2 2,697 Nov-10-2018, 01:54 AM
Last Post: Skaperen
  Python what should be name of the module for managing data of users ? harun2525 3 3,475 Dec-06-2017, 06:11 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020