[pypy-issue] [issue1156] Factory method behavior different from CPython

Mark Roberts tracker at bugs.pypy.org
Wed May 30 09:01:31 CEST 2012

Mark Roberts <wizzat at gmail.com> added the comment:

This is a difference in garbage collection:

class Test:
  def __init__(self):
    self.number = 5

  def returnTest(self):
    return Test()

t = Test()
tests = [ t.returnTest() for x in range(3) ]

mroberts at eternity8$ python2.7 te.py
[<__main__.Test instance at 0xb725b40c>, <__main__.Test instance at 0xb725b42c>, 
<__main__.Test instance at 0xb725b44c>]
mroberts at eternity8$ python3.2 te.py
[<__main__.Test object at 0xb6f8f40c>, <__main__.Test object at 0xb6f8f42c>, 
<__main__.Test object at 0xb6f8f44c>]
mroberts at eternity8$ pypy te.py
[<__main__.Test instance at 0xb6dac18c>, <__main__.Test instance at 0xb6dac1a0>, 
<__main__.Test instance at 0xb6dac1b4>]

status: chatting -> invalid

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list