-1

The title might be a bit misleading but I couldn't find a good way to express myself. Essentially if I had code like this:

def test_function(inputs):
    parameters = non_trivial_manipulation(inputs)
    return lambda x: some_function(parameters, x)

test = test_function(inputs)

My question is, does it go through all the manipulations in test_function every time I use test, or does Python somehow "cache" this so that the above code is actually efficient? If the latter, how does it do that?

Thanks!

Zhaoxin Wang
  • 11
  • 1
  • 3
  • When you call `test`, it only calls `lambda x: some_function(parameters, x)`, not `parameters = non_trivial_manipulation(inputs)`. – deceze Jan 24 '22 at 12:43

1 Answers1

-3

It isn't Python, it's the OS that caches it. The more you repeat something, the more cache the OS writes.

  • 1
    Because it's hardly clear what "OS caching" you're referring to, so it's likely wrong, *and* it's probably not the kind of caching OP is referring to either. – deceze Jan 24 '22 at 13:20
  • https://www.quora.com/What-is-caching-in-an-operating-system It's the first result from Google. – AndroGR Jan 24 '22 at 13:31