On 01.06.2016 17:17, Sven R. Kunze wrote:
... I hope that's not the only way to optimize it. :(
Well, if you restrict yourself to functions and objects, you can implement the assigning from within the code:
Instead of writing:
x = func('x')
and have func register itself with the globals under the given name:
def func(bindto): value = 'Hello World !' globals()[bindto] = value return value
>>> x 'Hello World !'
I am not that deep into CPython development in order to find a better solution but I think it should be possible for the compiler to find out whether a callee actually USES that information or not without any special decoration or something.
I don't see how that could work without being more explicit about the intention.