Let's imagine that I have some code like the following in RPython:

def wrapper_func(arg1, arg2):
    return inner_func(arg2)

def inner_func(x):
   for y in range(x):
      # do something here
      pass
   return -1

bigint = 1000000

wrapper_func(list(range(bigint)), bigint)

The problem here is that arg1 is going to be held onto in (in CPython at
least) until inner_func returns. This means that the list created on the
invocation of wrapper_func is going to stick around during the entire
execution time of inner_func. This would not make much of a difference
normally, but in languages with extensive use of lazy evaluation, holding
onto the head of a sequence could cause out-of-memory errors. In Clojure
this is fixed-up by the compiler via "locals clearing". Basically the
compiler inserts "arg1 = None" before the invocation of inner_func.

What's the story here in RPython? Since RPython basically compiles down to
single-assignment code I'm guessing the Clojure fix won't help me. When is
the GC able to go and free data held by arguments?



Timothy
_______________________________________________
pypy-dev mailing list
pypy-dev@python.org
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to