re: How Specific Are you With Your Imports and Why? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I'm not sure about "security reasons" (?) but there is a difference, albeit an insignificant one unless you are in a loop. This is what happens at...
 

So there is a performance benefit after all? That is very cool. The difference seems a bit on the academic side in this example, but since most of what I do deals in datasets that seem to get larger by the day, an academic difference over few iterations can be an enormous difference over thousands or more!

As far as security goes, I've never really been sure what was meant by that either. I was at a coding meetup in Portland, ME where I live and some other developers were talking about it. They used different languages than I did, mostly C, C++, and Java, and seemed to reference the fact that importing things you didn't need would leave those modules unintentionally usable from within the code that imported but didn't use them. I've never been all that low level and, though I have worked in a C-derivative language (C#) it was very early on in my career and only for about a year so I never got that deep with it. Either way, thanks for pointing out those docs! It really makes me think about what I am actually doing with imports that I take for granted so much at this point.

 

mostly C, C++, and Java, and seemed to reference the fact that importing things you didn't need would leave those modules unintentionally usable from within the code that imported but didn't use them

Ok got it. I'm not sure that's applicable to Python because you bring the runtime with you when you deploy the app and because you can import modules at runtime which means you can execute anything in the standard library and libraries packaged with the app. It also depends on what kind of security we're talking about but I'm not a real expert on the subject...

code of conduct - report abuse