Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FixLazyList.range [ci: last-only]#10767

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
BalmungSan wants to merge8 commits intoscala:2.13.x
base:2.13.x
Choose a base branch
Loading
fromBalmungSan:fix-lazy-list-range

Conversation

BalmungSan
Copy link
Contributor

SinceLazyList is not strict, there is not reason to makerange delegate throughfrom(NumericRange) which doesn't allow more thanInt.MaxValue elements.

@scala-jenkinsscala-jenkins added this to the2.13.15 milestoneApr 30, 2024
@SethTisueSethTisue requested a review froma teamApril 30, 2024 00:28
@SethTisueSethTisue added the library:collectionsPRs involving changes to the standard collection library labelApr 30, 2024
.range(start = 0L, end = totalElements)
.foldLeft(0L) { case (acc, _) =>
acc + 1L
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

even with inlining turned on, it's a lot to ask of a unit test. Maybe it's sufficient to test construction and head.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah I was wondering the same.
However, not sure if just asking for the head ensures there are more thanInt.MaxValue elements.

So not sure if there is a smart way to test this without it being a CPU trap.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Using a reverserange we don't need to compute a lot of elements.
Let me know what you think of the new test.
C.C.@NthPortal

@som-snyttsom-snytt changed the titleFixLazyList.rangeFixLazyList.range [ci: last-only]Apr 30, 2024
@som-snytt
Copy link
Contributor

added the magic title to avoid testing every commit

BalmungSan reacted with thumbs up emoji

.range(start = 0L, end = totalElements)
.foldLeft(0L) { case (acc, _) =>
acc + 1L
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah I was wondering the same.
However, not sure if just asking for the head ensures there are more thanInt.MaxValue elements.

So not sure if there is a smart way to test this without it being a CPU trap.

BalmungSanand others added2 commitsApril 30, 2024 11:32
Co-authored-by: Marissa | April <7505383+NthPortal@users.noreply.github.com>
Copy link
Contributor

@NthPortalNthPortal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

just two small changes; otherwise lgtm.

I agree with@som-snytt's concern about the cost of iterating overInt.MaxValue elements, though I'm not really sure what the alternative is. I will defer to others' judgement about whether or not to just skip it

BalmungSanand others added2 commitsApril 30, 2024 14:44
…tionCo-authored-by: Marissa | April <7505383+NthPortal@users.noreply.github.com>
Co-authored-by: Marissa | April <7505383+NthPortal@users.noreply.github.com>
}

private[this] def rangeImpl[A](start: A, end: A, step: A)(implicit ev: Integral[A]): State[A] =
if (ev.lt(start, end)) sCons(start, newLL(rangeImpl(ev.plus(start, step), end, step)))
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Uhm, wait, this does not allow reversed ranges, does it? LikeLazyList.range(start = 100, end = 0, step = -2)
I guess rather than check forlt we have to check for!ev.equiv(start, end)?

NthPortal reacted with thumbs up emojiNthPortal reacted with eyes emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Also, this made me think. This could be a good way to test this without a CPU trap. We just request the reversed range and then we can indeed ask for thehead and check it is bigger thanInt.MaxValue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

good point, the check is incorrect, hmm. probably need to check the sign or something as well. I'll have another look shortly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

my thought is to check the sign ofstep in the 3 parameter overload ofrange, and then pass it as aBoolean parameter (probably namedpositiveStep) torangeImpl, thus checking the condition only once rather than for each element

Copy link
ContributorAuthor

@BalmungSanBalmungSanApr 30, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I just pushed an implementation that allows for reverseranges.
Let me know what you think about it.

@SethTisue
Copy link
Member

@BalmungSan have you looked at the MiMa failures...?

@SethTisueSethTisue modified the milestones:2.13.15,2.13.16Aug 14, 2024
@BalmungSan
Copy link
ContributorAuthor

BalmungSan commentedAug 24, 2024
edited
Loading

@SethTisue hey, thanks for the pointer, I actually haven't noticed about the MiMa errors and was thinking the reason why the CI was red was that it was testing each commit.
Should I add the suggested filters? Or does that mean the changes can't be made until a future stdlib version?

@SethTisue
Copy link
Member

It looks to me like we're running into the problem described athttps://github.com/scala/improvement-proposals/blob/main/content/drop-stdlib-forwards-bin-compat.md#adding-overrides-for-performance . The overridden methods have return types ofCC which erases toObject, but the overrides have return types ofLazyList which erases toLazyList.

SIP-51 is accepted and has been implemented in at least one build tool (sbt), but we haven't actually started taking advantage of it yet.

At the moment we are still trying to ship 2.13.15, but once that is done, we can consider whether 2.13.16 is the release where we start actually using the new freedom.

BalmungSan reacted with thumbs up emoji

@SethTisue
Copy link
Member

we can consider whether 2.13.16 is the release where we start actually using the new freedom

update: 2.13.16 will be a modest compat/bugfix release, so 2.13.17 is now where we're looking to start bincompat breakage

BalmungSan reacted with thumbs up emoji

@SethTisueSethTisue modified the milestones:2.13.16,2.13.17Nov 6, 2024
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@som-snyttsom-snyttAwaiting requested review from som-snytt

@NthPortalNthPortalAwaiting requested review from NthPortalNthPortal is a code owner

Assignees
No one assigned
Labels
library:collectionsPRs involving changes to the standard collection librarylibrary:not-forward-bincompat
Projects
None yet
Milestone
2.13.17
Development

Successfully merging this pull request may close these issues.

5 participants
@BalmungSan@som-snytt@SethTisue@NthPortal@scala-jenkins

[8]ページ先頭

©2009-2025 Movatter.jp