Serhiy Storchaka added the comment: I agree and prefer #1. This will save users from incorrect using and us from reports about odd behavior.
The implementation is simple. The groupby object generates an unique identifier when creates a new grouper. This may be a sequential integer, just object(), or the grouper object itself (but the latter case creates a reference loop). The grouper object saves the parent's identifier when created and compare the owned reference with the current parent's identifier before every use (in __next__ and __reduce__). If they don't match, the grouper object is not valid. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30346> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com