JuliennedArrays.jl icon indicating copy to clipboard operation
JuliennedArrays.jl copied to clipboard

Slice exported from Base

Open bramtayl opened this issue 3 years ago • 9 comments

As of 1.9, so figure out what what to do about that...

bramtayl avatar Aug 26 '22 00:08 bramtayl

If I can make a suggestion, it would be nice if:

  1. Any features in this package missing from base were added there--which I believe is just Align--and
  2. This package provides all the Slices code if the Julia version in use is pre-1.9. That way, code relying on the new Slices object can be kept compatible with pre-1.9 just by adding this as a dependency.

ParadaCarleton avatar Nov 01 '22 00:11 ParadaCarleton

Thanks for the suggestion! I'm not sure about 1, I think that would be up to base. I haven't checked whether Slices in base does more or less things than the Slices that's here. I'm tempted to just rename the Slices here, but I also don't want to break anyone's code.

bramtayl avatar Nov 01 '22 18:11 bramtayl

No great suggestions, but if https://github.com/JuliaLang/Compat.jl/pull/663 is ever merged then Compat will provide the new Slices type.

mcabbott avatar Nov 01 '22 18:11 mcabbott

Thanks for the suggestion! I'm not sure about 1, I think that would be up to base. I haven't checked whether Slices in base does more or less things than the Slices that's here. I'm tempted to just rename the Slices here, but I also don't want to break anyone's code.

I think it's nearly identical, but @simonbyrne would know better than me.

ParadaCarleton avatar Nov 01 '22 18:11 ParadaCarleton

@bramtayl I've checked, and the only differences are:

  1. The Slices in Base don't implement Align.
  2. The Slices in Base are constructed using eachslice, and don't have a constructor method Slices(array, dims...). I'm guessing both the additional constructor and Align would be welcomed as pull requests, but Align can stay here if not.

Making old JuliennedArrays code compatible with 1.9 would just require adding a Slices constructor to base, and then having this package define Slices only for versions before 1.9.

ParadaCarleton avatar Nov 04 '22 01:11 ParadaCarleton

Ok. Sure, PR's welcome. If you want to submit a PR to base for align, feel free, but I haven't had to much luck with similar PR's.

bramtayl avatar Nov 04 '22 16:11 bramtayl

The eager Align is stack, and my understanding is that people were not so keen on adding a lazy version. While a view from eachcol is almost always as good as a dense array, this is not true of the fragmented view made by things like Align.

mcabbott avatar Nov 04 '22 18:11 mcabbott

The eager Align is stack, and my understanding is that people were not so keen on adding a lazy version. While a view from eachcol is almost always as good as a dense array, this is not true of the fragmented view made by things like Align.

That makes some sense, but what's the problem with having both? Sometimes copying is less efficient than returning a lazy view. Julia provides lazy versions of some other functions, like map vs Iterators.map, for exactly this reason.

ParadaCarleton avatar Nov 11 '22 23:11 ParadaCarleton

Looks like there's not much interest in a PR to base; in that case, I think the package should be able to just implement a Slices constructor following the old syntax that forwards the method to Base, to avoid breaking any packages.

ParadaCarleton avatar Nov 23 '22 17:11 ParadaCarleton