title: Python: create a function to modify a list by reference not value
body: <p>I'm doing some performance-critical Python work and want to create a function that removes a few elements from a list if they meet certain criteria.  I'd rather not create any copies of the list because it's filled with a lot of really large objects. </p>
  
  <p>Functionality I want to implement:</p>
  
  <pre><code>def listCleanup(listOfElements):
      i = 0
      for element in listOfElements:
          if(element.meetsCriteria()):
              del(listOfElements[i])
          i += 1
      return listOfElements
  
  myList = range(10000)
  myList = listCleanup(listOfElements)
  </code></pre>
  
  <p>I'm not familiar with the low-level workings of Python.  Is myList being passed by value or by reference?   </p>
  
  <p>How can I make this faster?</p>
  
  <p>Is it possible to somehow extend the list class and implement listCleanup() within that?</p>
  
  <pre><code>myList = range(10000)
  myList.listCleanup()
  </code></pre>
  
  <p>Thanks-</p>
  
  <p>Jonathan</p>