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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:53:59+00:00 2026-06-03T08:53:59+00:00

I am a Java programmer and I have always created separate files for Classes,

  • 0

I am a Java programmer and I have always created separate files for Classes, I am attempting to learn python and I want to learn it right.
Is it costly in python to put Classes in different files, meaning one file contains only one class. I read in a blog that it is costly because resolution of . operator happens at runtime in python (It happens at compile time for Java).

Note: I did read in other posts that we can put them in separate files but they don’t mention if they are costlier in any way

  • 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-03T08:54:01+00:00Added an answer on June 3, 2026 at 8:54 am

    It is slightly more costly, but not to an extent you are likely to care. You can negate this extra cost by doing:

    from module import Class
    

    As then the class will be assigned to a variable in the local namespace, meaning it doesn’t have to do the lookup through the module.

    In reality, however, this is unlikely to be important. The cost of looking up something like this is going to be tiny, and you should focus on doing what makes your code the most readable. Split classes across modules and packages as is logical for your program, and as it keeps them clear.

    If, for example, you are using something repeatedly in a loop which is a bottleneck for your program, you can assign it to a local variable for that loop, e.g:

    import module
    
    ...
    
    some_important_thing = module.some_important_thing
    
    #Bottleneck loop
    for item in items:
       #module.some_important_thing()
       some_important_thing()
    

    Note that this kind of optimisation is unlikely to be the important thing, and you should only ever optimise where you have proof you need to do so.

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

Sidebar

Related Questions

I have programmed in HTML, Java, CSS, C++, VB, an Python. I'm looking to
I am a Java programmer and need to work on a Flex/ActionScript project right
I have a little problem with Java (being a C++ programmer). I have 2
I have been a Java programmer for a while and I am trying to
I am a Java programmer looking to learn .NET, particularly C# and F#, to
I'm an experienced Java programmer that for the last two years have programmed for
I am a java programmer and I want to use MongoDB in my project.
I am not a Java programmer. I program R and C++. I have some
I have always thought that the .equals() method in java should be overridden to
I have been a Java programmer for the last 6 years, and since the

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.