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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:02:16+00:00 2026-06-07T16:02:16+00:00

So I have two modules A and B, and another installed module C. Say

  • 0

So I have two modules A and B, and another installed module C. Say I use some methods of C in A and B. I also need module A in B. So logically my imports would be :

A :

import C

B :

import A

Logic would tell me that B would contain functions from A and C. However this doesnt work this way by default. In the sense that to refer to any functions in C in module A, we need the extra level of namespace reference

A.C.some_c_module()

I found out that we can import C in both A and B without the use of pesky “C language like” ifdef clones,and it would work fine. My question is, does importing such modules twice come with a penalty? In the sense that is python smart enough to know that A.C.some_module == C.some_module? Or am I just being a bad boy by doing this?

  • 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-06-07T16:02:18+00:00Added an answer on June 7, 2026 at 4:02 pm

    Importing a module twice doesn’t result in it being loaded twice. Python loads the module once and keeps a reference to it. So yes, Python is smart enough to know that the two versions are the same. You can import the module as much as you want and it will only “cost” you once.

    Incidentally, the reason that “B would contain functions from A and C” is false is that when you do import C in A.py, A does not “contain functions from C”. Rather, A contains a reference to C itself. So when you import A from inside B, you get the reference to C, not references to the functions inside C. If you import individual parts of C directly into A’s namespace by using from C import blahBlah, then when you import A you will have access to those functions as members of A.

    # A.py
    from C import blah
    
    # B.py
    import A
    A.blah # this will work
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have two modules. Is it possible to include a module inside
say I have two 'modules'. For instance the hardware-interface layer of a RS-232 port
I have two different modules that need access to a single file (One will
I have a Maven multi-module project and I need two different parent POMs in
I have in my python workspace two Modules which need sip.pyd Module1.pyd needs sip.pyd
I am working on a transliteration tool. I have two modules lexer and translator.
I have these two modules : package G1; sub new { my $class =
In my code base I find that two modules have structures with the same
I have an application (CC) containing two modules: CC-ejb and CC-war. CC-ejb contains JPA
I have written a Python module, and I have two versions: a pure Python

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.