pass the __dict__ item of a class __dict__#291
pass the __dict__ item of a class __dict__#291pierreglaser wants to merge 16 commits intocloudpipe:masterfrom
Conversation
ca0c8c8 to
cdd0aa7
Compare
|
Arg, this code is not safe with regards to reference cycles when |
Codecov Report
@@ Coverage Diff @@
## master #291 +/- ##
===========================================
- Coverage 92.84% 55.83% -37.01%
===========================================
Files 2 2
Lines 852 849 -3
Branches 177 176 -1
===========================================
- Hits 791 474 -317
- Misses 37 347 +310
- Partials 24 28 +4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #291 +/- ##
==========================================
+ Coverage 92.84% 93.07% +0.23%
==========================================
Files 2 2
Lines 852 852
Branches 177 177
==========================================
+ Hits 791 793 +2
+ Misses 37 36 -1
+ Partials 24 23 -1
Continue to review full report at Codecov.
|
|
Some updates: now that The guard if not isinstance(obj, types.GetSetDescriptorType) and getattr(__dict__, '__objclass__', None), is not objserves the purpose of finding this default case. Also, now that we special-case the situation where |
Codecov Report
@@ Coverage Diff @@
## master #291 +/- ##
==========================================
+ Coverage 92.84% 93.07% +0.23%
==========================================
Files 2 2
Lines 852 852
Branches 177 177
==========================================
+ Hits 791 793 +2
+ Misses 37 36 -1
+ Partials 24 23 -1
Continue to review full report at Codecov.
|
|
The failure of |
In from collections import namedtuple
namedtuple_class = namedtuple('MyTuple', ['a', 'b', 'c'])is overriden so that instances of these classes: t = namedtuple_class('foo', 'bar', 'qux')have their >>> t.__dict__
OrderedDict([('a', 'foo'), ('b', 'bar'), ('c', 'qux')])
>>> type(namedtuple.__dict__['__dict__'])
property(corresponding line in Visibly, cloudpickle was aware of that use case cloudpickle/cloudpickle/cloudpickle.py Lines 645 to 649 in 2db58f1 It turns out that commenting the lines lines 648-649 does not break the test suite: there is no need to save So IMO, those lines in cloudpickle do not serve any use-case. In addition, they are pretty hard to understand at first sight. So I wanted to clarify the way we handle the presence of a There are two ways we can do that:
I am fine with both ways. I simply stumbled across those lines many times, and was always confused by their purpose/the use-case they served - this PR was an attempt to rationalize and clearly document them. Suggestions welcomed. |
Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org>
Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org>
Closes #282