Skip to main content

New answers tagged

3 votes

What side-effects, if any, are okay when importing a python module?

One big issue with your example logging code is that both those lines of code could fail for a multitude of reasons (read-only filesystem, invalid path, lack of filesystem permissions, etc). These ...
bta's user avatar
  • 1,161
-3 votes

What side-effects, if any, are okay when importing a python module?

TL;DR Side effects are unacceptable until they are unavoidable. Convention Python libraries are "quick and dirty" - they rely heavily on global shared state and there is little to be done ...
Basilevs's user avatar
  • 2,268
13 votes

What side-effects, if any, are okay when importing a python module?

However, in a lot of cases, the side-effects are hard to avoid or may be desirable. They are never hard to avoid, and they are never desirable. Or maybe they somewhat are hard to avoid, because it ...
freakish's user avatar
  • 1,926
21 votes

What side-effects, if any, are okay when importing a python module?

logging # Creates a logfile logging.basicConfig(filename="module.log") No, don't do it! Now git status is dirty, it shows an untracked file. Protect this with a __main__ guard, or let ...
J_H's user avatar
  • 7,600
6 votes
Accepted

When the stack frames become computationally expensive

There are two questions here: What is the cost of function call? Is inlining a function worth it? So first of all a function call costs. Saving registers, setting up frame, two jumps, loading ...
freakish's user avatar
  • 1,926
-1 votes

When the stack frames become computationally expensive

function call overhead When you speak of stack frames that are "computationally expensive" you're really talking about the expense incurred to save state, transmit arguments, receive result, ...
J_H's user avatar
  • 7,600

Top 50 recent answers are included