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

Enhancement: left and right shifting support #7

Closed
skrossner opened this issue Jun 30, 2012 · 12 comments
Closed

Enhancement: left and right shifting support #7

skrossner opened this issue Jun 30, 2012 · 12 comments

Comments

@skrossner
Copy link

Can you add support for the << and >> operators? Perhaps look at https://bitbucket.org/quiark/bitarray/src/473cb720d09d/bitarray/_bitarray.c for a reference. Thanks.

@Pimmetje
Copy link

Pimmetje commented Jan 3, 2015

+1

2 similar comments
@eli-b
Copy link

eli-b commented Mar 18, 2015

+1

@wmayner
Copy link

wmayner commented Apr 9, 2015

+1

@xanderdunn
Copy link

Yes pwease. Don't forget right and left rotates (or "circular shifts")!

@xanderdunn
Copy link

Actually, it looks like one of the outstanding pull requests has this implemented: #8

But, it's been open since September 2012. 😭

@rwmanos
Copy link

rwmanos commented Sep 11, 2017

+1

@rrrealman
Copy link

Hi guys, is there still need in simple shifts? As I found here, it was not merged. So, I need this implementation and have time to commit it.

@adavidzh
Copy link

I just got here because I could not believe that << and >> were not implemented. @ilanschnell, any chance you can look into the related PRs?

@eddydee123
Copy link

eddydee123 commented Jan 7, 2020

@ilanschnell is there any reason not to merge the PR for this feature? Seems like it's an obvious enhancement...
Thanks!

@ilanschnell
Copy link
Owner

I have been thinking about shift operations for a long time, and tried an implementation in a branch. However, as bitarrays are arrays (and not integers) it seems strange why they should support shift operations. The Python list object (as well as Python's array library) does not support shift operations either.

@wmayner
Copy link

wmayner commented Apr 2, 2021

IMHO, it depends on the intended scope of the library. If it's meant to be a drop-in replacement for list, then perhaps not... but, for example, I would like to use it to deal with the states of dynamical systems with binary-valued elements. Each bit represents the state of a separate element, but when dealing with the phase-space algorithmically it's often convenient & efficient to treat the states as base-2 integers. For that kind of use-case, left and right shift would be useful.

Just my two cents :)

@ilanschnell
Copy link
Owner

Thanks @wmayner for your input.

While it is the list object doesn't support shifts, it also doesn't support &, ^, etc. , while bitarray supports those operations. While bitarray objects support all list methods, it has many more that are specific to bitarrays. I have therefore decided that adding support for shift operations is a good idea, and created #117. I plan to merge #117 before the next release. Please comment on #117 . Thanks!

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

No branches or pull requests

10 participants