This is in context of a Python module written in Nim.

I have a Nim procedure that Python will use, that will be compiled using 
**\--gc:none** and I want it to work like this: 
    
    
    proc pythonProc(self, args: ptr PyObject) =
      var
        tempString: string
        tempSeq: seq[string] = newSeq[string]()
      
      ... # Some code that does some work
      
      ??? # How to clean up tempString and tempSeq manually ?
    

Is there a way to implement manual variable cleanup (the last line) with 
**\--gc:none** and without resorting to **alloc/dealloc**?

Right now I'm compiling **with the GC enabled** and doing this: 
    
    
    proc pythonProc(self, args: ptr PyObject) =
      var
        tempString: string
        tempSeq: seq[string] = newSeq[string]()
      
      GC_disable() # Needed because some OS'es throw a segfault with the GC 
enabled
      
      ... # Some code that does some work
      
      GC_enable()
      GC_fullcollect()
    

Reply via email to