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

add docstring for small threshold #54602

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

danik292
Copy link
Contributor

Part of #52725

base/sort.jl Outdated
"""
SMALL_THRESHOLD

SMALL_THRESHOLD is constant for internally decide, whatever is arrey considered small or big
Copy link
Contributor

Choose a reason for hiding this comment

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

A few pointers:

This has spelling errors and is not grammatically correct (in fact I have trouble figuring out what it tries to say).

In addition: this line shouldn't be indented, there should be an empty line before this docstring, and it shouldn't end in an empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I will fix it when I get to the computer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its better now?

@mbauman mbauman added docs This change adds or pertains to documentation sorting Put things in order labels May 29, 2024
base/sort.jl Show resolved Hide resolved
"""
SMALL_THRESHOLD

SMALL_THRESHOLD is a constant that is used internally to decide what is considered to be small or large.
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a lot better already, but it isn't yet all that helpful as it gives no indication about the context in which it is used, i.e. what "small" or "large" mean or affect.

I think something to the effect of: for vectors with less (?) than SMALL_THRESHOLD elements, sorting switches to a different algorithm SMALL_ALGORITHM, otherwise it uses the big algorithm. This is in particular relevant for recursive sorting algorithms which reduce to smaller sublists, sort those and combine the result.

Note that SMALL_ALGORITHM also has a docstring.

Copy link
Member

Choose a reason for hiding this comment

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

The threshold at which to switch sorting algorithms based on size is also quite variable. SMALL_THRESHOLD is only used in some cases (e.g. QuickSort and MergeSort)

@oscardssmith
Copy link
Member

Why is this a public/exported constant at all? Shouldn't it just be private?

@LilithHafner
Copy link
Member

LilithHafner commented May 31, 2024

It should be private but it's exported from the public module Sort.

julia> using Base.Sort

julia> SMALL_THRESHOLD
20

julia> VERSION
v"1.0.5"

Co-authored-by: Max Horn <max@quendi.de>
@danik292
Copy link
Contributor Author

danik292 commented Jun 1, 2024

What is a right use of constant witch i should describe in docstring?

@LilithHafner
Copy link
Member

For the most part, I don't think folks should be using it in code. They may wish to refer to it when understanding how the internals work, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This change adds or pertains to documentation sorting Put things in order
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants