Skip to content
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

Operators are returning explicitly intbitset #42

Closed
kaplun opened this issue May 5, 2016 · 1 comment
Closed

Operators are returning explicitly intbitset #42

kaplun opened this issue May 5, 2016 · 1 comment

Comments

@kaplun
Copy link
Member

kaplun commented May 5, 2016

@pombredanne reports in #40:
[...]
there is still something not right though IMHO:

>>> class MySet(intbitset):
...     def __init__(self, a1, a2):
...         self.union_update(range(a1, a2))
... 
>>> a=MySet(0, 12)
>>> b=MySet(5, 15)
>>> a|b
intbitset([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

I would expect a MySet object instead of an intbitset.

For instance with a set:

class SubSet(set):
    def __init__(self, a1, a2):
        super(SubSet, self).__init__(range(a1, a2))

I get the right subclass:

>>> a=SubSet(0, 12)
>>> b=SubSet(5, 15)
>>> a|b
SubSet([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])

[...]

Indeed this is due to the fact that the intbitset methods and operators explicitly return a new intbitset object rather than an instance of the desired class.

@pombredanne
Copy link
Collaborator

I do not think it is a big deal... I am fine with not subclassing but delegating instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants