[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2018-01-05 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 2.7

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2017-11-30 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset c91bf742e542dceaf71042a44b5a04fb08bdda70 by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.6':
bpo-28416: Break reference cycles in Pickler and Unpickler subclasses (GH-4080) 
(#4653)
https://github.com/python/cpython/commit/c91bf742e542dceaf71042a44b5a04fb08bdda70


--

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2017-11-30 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +4565

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2017-11-30 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 986375ebde0dd5ff2b7349e445a06bd28a3a8ee2 by Serhiy Storchaka in 
branch 'master':
bpo-28416: Break reference cycles in Pickler and Unpickler subclasses (#4080)
https://github.com/python/cpython/commit/986375ebde0dd5ff2b7349e445a06bd28a3a8ee2


--

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2017-10-23 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2017-10-23 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

PR 4080 converts bound methods into unbound methods if possible.

--

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2017-10-22 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
versions:  -Python 3.5

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2016-10-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka
type: behavior -> resource usage
versions: +Python 2.7, Python 3.6, Python 3.7

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2016-10-11 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +alexandre.vassalotti

___
Python tracker 

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



[issue28416] defining persistent_id in _pickle.Pickler subclass causes reference cycle

2016-10-11 Thread Carl Witty

New submission from Carl Witty:

On creation, _pickle.Pickler caches any .persistent_id() method defined by a 
subclass (in the pers_func field of PicklerObject).  This causes a reference 
cycle (pickler -> bound method of pickler -> pickler), so the pickler is held 
in memory until the next cycle collection.  (Then, because of the pickler's 
memo table, any objects that this pickler has pickled are also held until the 
next cycle collection.)

Looking at the source code, it looks like the same thing would happen with 
_pickle.Unpickler and .persistent_load(), but I haven't tested it.  Any fix 
should be applied to both classes.

I've attached a test file; when I run it with "python3 
pickle_reference_cycle.py", all 3 print statements are executed.  I would 
prefer it if "Oops, still here" was not printed.  (I'm using Debian's python3.5 
package, version 3.5.2-4 for amd64, but I believe the problem occurs across 
many versions of python3, looking at the history of _pickle.c.)

I don't see how to fix the problem with no performance impact.  (Setting 
pers_func at the beginning of dump() and clearing it at the end would have 
approximately the same performance in the common case that only one object was 
dumped per pickler, but would be slower when dumping multiple objects.)  If you 
decide not to fix the problem, could you at least describe the problem and a 
workaround in the documentation?

--
components: Extension Modules
files: pickle_reference_cycle.py
messages: 278495
nosy: cwitty
priority: normal
severity: normal
status: open
title: defining persistent_id in _pickle.Pickler subclass causes reference cycle
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file45058/pickle_reference_cycle.py

___
Python tracker 

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