Functions unnecessarily called in Python/pylifecycle.c:_Py_InitializeCore() ?

Thomas Nyberg tomuxiong at gmx.com
Thu Mar 1 07:40:16 EST 2018


On 03/01/2018 12:46 PM, bartc wrote:
> If they're only called once, then it probably doesn't matter too much in
> terms of harming performance.

Oh yeah there's no way this has any affect on performance. A smart
compiler might even be able optimize the call away entirely. Even if it
couldn't, it's about as fast as an operation could possibly be.

> As for leaving them in, there might be a number of reasons. One, if one
> day some special initialisation does need to be done, then this gives a
> place to put it.
> 
> I quite often have an initialisation routine for a module, that
> sometimes ends up empty, but I keep it in anyway as often things can get
> added back.

Yeah I figure this is the reasoning. Personally I don't like having
noops for this sort of code structure reasoning, but I can see how rules
like "everything gets init'ed" is also a fair strategy. Half of my
question was simply whether that is the case or if possible it was just
a mistake when older versions that did something could be removed (e.g.
the code example you put int).

Thanks for the response!

Cheers,
Thomas



More information about the Python-list mailing list