20 Apr
2007
20 Apr
'07
5:32 p.m.
Brett Cannon schrieb:
True, but it does introduce an import for a module that may never be used if the module is not being executed. That kind of sucks for minor performance reasons.
Yeah but sys is used by a lot of modules. Probably 95%+ of executable modules are either using sys directly to access sys.argv or os which imports sys. Also sys is a builtin module which is imported ridiculously fast. I assume that the speed penalty for scripts that don't use sys is minor. In my humble opinion it sucks less to force the import of a core module that is already used by most modules than to bind valuable developer time in the __main__ approach. I think it's a Pythonic solution as well. :) Christian