from xx import yy

Chris Angelico rosuav at gmail.com
Mon Nov 13 12:58:11 EST 2017


On Tue, Nov 14, 2017 at 3:58 AM, bvdp <bob at mellowood.ca> wrote:
> Thanks all for confirming that I was wrong to use "from .. import". Hmmm, perhaps for functions it might be okay. But, in most cases it's a lot more obvious to use module.function() when calling. Maybe a bit slower, but I'm sure it's negligible in most cases.
>
> And, yes, I am trying to share state info between modules. Is this a bad thing? I guess I would write getter() and setter() functions for all this. But that does seem to remind me too much of some other language :)
>

It's going to be so very marginally slower that you won't even be able
to measure it, outside of a micro-benchmark. Worry about code
correctness first, and then performance only if you actually know you
have a problem.

Sharing state between modules is fine as long as it's controlled by
one module - which is what you have here. Go ahead! Not an issue.

ChrisA



More information about the Python-list mailing list