Open mrocklin opened 10 years ago
I agree that it seems convoluted. Perhaps this is also a great place for separation of concerns by having a CarrayIterator.
If you look at the following blog post:
https://stackoverflow.com/questions/19151/build-a-basic-python-iterator
It seems like the right thing to do may be to have the carray implement __iter__
and the CarrayIterator to implement next()
and __next__
.?
That follows my intuition.
Here is another 'blueprint' I found:
http://www.shutupandship.com/2012/01/understanding-python-iterables-and.html
So, after pondering on this some more, I think the reason why the iterator is 'fused' into the carray is so that it can use the io buffer of the carray. Some hints:
https://github.com/Blosc/bcolz/blob/master/bcolz/carray_ext.pyx#L2272
https://github.com/Blosc/bcolz/blob/master/bcolz/carray_ext.pyx#L2431
Also, it is worth noting, that the Iterator isn't actually the original carray
but in fact a view()
of it.
This is odd behavior
This is because (I think) bcolz.carray implements a
__next__
method which is (I think) inappropriate for a data container (it being more appropriate for a stateful iterator).Is this intended? Should it be fixed?
Related to #37