New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shortcut operators for union, intersection and difference #144
Shortcut operators for union, intersection and difference #144
Conversation
6b6352e
to
52946fb
Compare
52946fb
to
5f15484
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good to me! Thank you!
I think the only things missing are a change note about the added operators and a mention in the documentation. I think we should say what types support these operations with what sort of arguments — it's not entirely clear to me. It's probably fine to just refer to the original functions. Our sphinx configuration for autodoc does document special members, but I don't see any docstrings for these. It may be best to add them to the interfaces and document them there.
The number protocols methods ``__and__``, ``__or__`` and ``__sub__`` are provided | ||
by all the data structures. They are shortcuts for :meth:`~BTrees.Interfaces.IMerge.intersection`, | ||
:meth:`~BTrees.Interfaces.IMerge.union` and :meth:`~BTrees.Interfaces.IMerge.difference`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just set this line of documentation because I was not sure on which interface to add the new operators. Is it ok like this? Or should I add the operators to the IBTree, ITreeSet and ISet interfaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the modules (e.g., BTrees.OOBTree
) that implement IMerge
, so I don't think the method definitions of the operators belong here. It doesn't hurt anything to mention in the main docstring here that there are operator synonyms for the functions defined by this interface, but I think that the operator method definitions should be moved to the appropriate datatype interfaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, just to be sure, IBTree, ITreeSet and ISet ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds right to me. (I don't think there's an IBucket
.)
All the OS X builders failed because
no Sphinx markup is allowed in README.rst and CHANGES.rst because those are used for long_description. (In the past I've sometimes resorted to a judicious str.replace() to overcome this problem.) |
@@ -5,7 +5,11 @@ | |||
4.7.3 (unreleased) | |||
================== | |||
|
|||
- Nothing changed yet. | |||
- BTrees, TreeSet, Set and Buckets implements the ``__and__``, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Since the |
Everything should be good now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thank you!
I just have two minor nits.
Fixes #142
Implementation of
__sub__
,__or__
and__and__
as shortcuts fordifference
,union
andintersection
.This makes the usage of BTrees datastructures closer to native python sets, that support those operators.