[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-26 Thread tzickel


tzickel  added the comment:

Sorry ignore it. Closed the PR as well.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-26 Thread tzickel


tzickel  added the comment:

Is this commit interesting ? It has less lines, more simple and makes no cycles 
to collect, and it seems in my limited benchmark faster than the current 
implementation. 

https://github.com/tzickel/cpython/commit/7e8b70b67cd1b817182be4dd2285bd136e6b156d

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-24 Thread STINNER Victor


STINNER Victor  added the comment:

rhettinger: "status: open -> closed"

I guess that https://github.com/python/cpython/pull/10002 should be closed as 
well?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-24 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-24 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +eric.snow, vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-23 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> I see, so basically this would be a problem only if the root 
> object had a __del__ method and then the GC wouldn't reclaim it ?

Yes.  That's exactly it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-20 Thread tzickel


tzickel  added the comment:

I see, so basically this would be a problem only if the root object had a 
__del__ method and then the GC wouldn't reclaim it ?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-20 Thread tzickel


tzickel  added the comment:

You can see the testing code here:

https://github.com/numpy/numpy/blob/eb40e161e2e593762da9c77858343e3720351ce7/n
umpy/testing/_private/utils.py#L2199

it calls gc.collect in the end and only throws this error if it returns a non 
zero return value from it (after clearing the gc before calling the test code).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I'm unclear whether you're reporting a true leak (one that can't be cleaned-up 
by a call to gc.collect()) or just a garden variety circular reference that 
will eventually free, just not as quickly as it would with straight reference 
counting applied when there are no circular references.

FWIW, there wasn't a backport because the latter case wasn't deemed to be bug.  
Circular references are allowed -- we just wait on GC to clean them up.  

Another consideration was that the weakref proxy alternative was much slower 
than the existing code (that mattered less in Python 3 where we have a C 
implementation of OrderedDict, giving more freedom for the pure python version 
to adopt a less performant but more memory friendly alternative).  There is a 
little more history here as well.  There used to be a __del__() method to 
accelerate the reclamation of memory but that was slow and it occasionally 
caused other problems such as the creation of an unreclaimable zombie object.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-20 Thread Karthikeyan Singaravelan

Karthikeyan Singaravelan  added the comment:

Thanks for the report. I have converted the numpy code as a python helper and I 
am not sure if such a helper exists in the current test suite. Attaching the 
file that might help as a simple reproducer.

# On master no error

➜  cpython git:(master) ./python.exe ../backups/bpo35030.py

# upstream/2.7 branch

➜  cpython git:(2bad7acdfe) ✗ ./python.exe ../backups/bpo35030.py
Traceback (most recent call last):
  File "../backups/bpo35030.py", line 60, in 
del a
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/contextlib.py", 
line 24, in __exit__
self.gen.next()
  File "../backups/bpo35030.py", line 53, in assert_no_gc_cycles
) for o in objects_in_cycles
AssertionError: Reference cycles were found: 1 objects were collected, of which 
1 are shown below:
  list object with id=4475647608:
[,
 ,
 None]

--
nosy: +xtreak
Added file: https://bugs.python.org/file47885/bpo35030.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-20 Thread tzickel


Change by tzickel :


--
keywords: +patch
pull_requests: +9344
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35030] Python 2.7 OrderedDict creates circular references

2018-10-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
title: Python 2.7 OrderedDict leaks memory -> Python 2.7 OrderedDict creates 
circular references

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com