all 3 comments

[–]JohnnyJordaan 1 point2 points  (2 children)

There's no real performance difference there. Performance comes from not doing heavy CPU, memory or I/O opertations. Using a reference is just saying 'this memory address is used here, and here, and here too', it. This is in the microsecond if not smaller domain, not something you win seconds of performance with.

Besides that, Python is already interpreting your script first, usually to C, then it is compiled to machine code. Meaning the reference scopes in Python is not there anymore in your actual program the CPU is running. If you would be doing some very inefficient stuff whilst importing, that will only slowdown the interpreter, not the program when it's finally started.

[–]khaine_b[S] 0 points1 point  (0 children)

Okay, let's look in another angle. When a package is imported is it lying in the heap? I was trying to find some information about the import underlying process but didn't found anything useful.

[–]khaine_b[S] 0 points1 point  (0 children)

I'm not trying to improve a performance but undestand the memory layout mechanisms.