Skip to content

Conversation

@barucden
Copy link
Contributor

@barucden barucden commented Sep 27, 2021

A bug was introduced for 3 arguments version of intersect in #41769. The container type always changed to Set. See this comment.

master:

julia> intersect(BitSet([1,2]), [1,2], [2])
Set{Int64} with 1 element:
  2

After this PR:

julia> intersect(BitSet([1,2]), [1,2], [2])
BitSet with 1 element:
  2

julia> intersect(BitSet([1,2]), [1,2], [2.0])
Set{Float64} with 1 element:
  2.0

I kindly ask you to suggest improvements as this PR introduces a slow-down (compared to 1.6.2):

# 1.6.2
julia> @btime intersect(BitSet([1,2]), [1,2], [2])
  397.583 ns (12 allocations: 768 bytes)
BitSet with 1 element:
  2
# PR
julia> @btime intersect(BitSet([1,2]), [1,2], [2])
  516.840 ns (15 allocations: 928 bytes)
BitSet with 1 element:
  2

EDIT: cc @vtjnash who first noticed this bug

@JeffBezanson
Copy link
Member

Maybe we could get the performance back by skipping the copy when T == promote_eltype(s, itr)?

@barucden
Copy link
Contributor Author

barucden commented Oct 2, 2021

Thanks @JeffBezanson! Now the timings are the same:

# this PR
julia> @btime intersect(BitSet([1,2]), [1,2], [2])
  384.952 ns (12 allocations: 752 bytes)
BitSet with 1 element:
  2
# 1.6.3
julia> @btime intersect(BitSet([1,2]), [1,2], [2])
  385.292 ns (12 allocations: 768 bytes)
BitSet with 1 element:
  2

A bug was introduced for 3 arguments version of `intersect` in JuliaLang#41769.
The container type always changed to `Set`:

```
julia> intersect(BitSet([1,2]), [1,2], [2])
Set{Int64} with 1 element:
  2
```

This is an attempt to return to the original behavior:

```
julia> intersect(BitSet([1,2]), [1,2], [2])
BitSet with 1 element:
  2
```
@barucden
Copy link
Contributor Author

barucden commented Oct 8, 2021

Is more work required here, or can we merge it?

@fredrikekre fredrikekre merged commit e95f949 into JuliaLang:master Oct 10, 2021
@barucden barucden deleted the intersect-fix branch October 10, 2021 13:06
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
A bug was introduced for 3 arguments version of `intersect` in JuliaLang#41769.
The container type always changed to `Set`:

```
julia> intersect(BitSet([1,2]), [1,2], [2])
Set{Int64} with 1 element:
  2
```

This is an attempt to return to the original behavior:

```
julia> intersect(BitSet([1,2]), [1,2], [2])
BitSet with 1 element:
  2
```
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
A bug was introduced for 3 arguments version of `intersect` in JuliaLang#41769.
The container type always changed to `Set`:

```
julia> intersect(BitSet([1,2]), [1,2], [2])
Set{Int64} with 1 element:
  2
```

This is an attempt to return to the original behavior:

```
julia> intersect(BitSet([1,2]), [1,2], [2])
BitSet with 1 element:
  2
```
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

Successfully merging this pull request may close these issues.

5 participants