Remove abc inheritance from Serializable - #8254
Conversation
|
Here are some back of the envelope benchmarks run using IPython's
|
Codecov Report
@@ Coverage Diff @@
## branch-21.06 #8254 +/- ##
===============================================
Coverage ? 82.89%
===============================================
Files ? 105
Lines ? 17934
Branches ? 0
===============================================
Hits ? 14866
Misses ? 3068
Partials ? 0 Continue to review full report at Codecov.
|
|
LGTM. @jakirkham could you please take a quick look too when you have a moment? :) |
|
Are there use cases where this |
@jakirkham Yes, unfortunately. In an ideal world we would rely on ducktyping everywhere, but that's definitely not the case internally for various reasons. As a result, lots of different code paths are impacted here. I included a benchmark above of the difference in constructing an Index from different types, here's the relevant data again:
That was just intended as a representative example. The same type of difference will be observed in a large number of different operations. Take this simple binop example (run via IPython): The before/after numbers there are In addition, removing |
|
@gpucibot merge |
Currently the Serializable class provides
serializeanddeserializeasabstractmethods via the mechanisms afforded by inheritance fromabc.ABC. Since this class is purely internal tocudfand is not describing an abstract interface in a manner useful to consumers of our code, the benefits of the abstract base class concept are outweighed by the performance and maintenance costs. In particular,isinstancechecks on subclasses ofabc.ABCare much more expensive than for normal classes (due to an expensive implementation of__instancecheck__), and (for better or worse) our code base currently makes use of these checks extensively. In addition, in certain places we can benefit from the use of custom metaclasses incudf, but their usage becomes more cumbersome withABCbecause metaclasses then also have to inherit fromABCMeta(which brings along any associated complexities). This PR removes that inheritance, replacing it with a much simpler approach that simply implementsserializeanddeserializeas raisingNotImplementedError.