[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime
From: |
G. Branden Robinson |
Subject: |
Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n |
Date: |
Wed, 13 Mar 2024 13:00:57 -0500 |
Hi James,
At 2024-03-12T15:28:22-0400, James K. Lowden wrote:
> On Wed, 13 Mar 2024 06:52:10 -0500
> "G. Branden Robinson" <g.branden.robinson@gmail.com> wrote:
>
> > A hash table (or map) of size 1 is not a hash table, it's a list.
>
> A container does not change its type based on its size.
Indeed not. I was speaking at a conceptual level, rather than in a
`typeof` sense.
In Python, for example, the following is silly (for more than one
reason).
thing = "This is my string."
thing_length = [ len(thing) ]
i = 0
while i < thing_length[0]:
print(thing[i])
i += 1
What is the point of the singleton list? Why have the overhead of an
aggregate type when an atomic one will serve?
Similarly, there's no point in a two-dimensional structure like an
associative array of lists if your array has only one element and you
walk the list until finding a match anyway.
So no, a container doesn't change its type based on its size, but if
you're using a more complex one where a simpler one will do, you might
want to rethink.
> I don't know what you're trying to fix here, but it sounds
> unimportant. If the user is creating, let us say, unnecessary or
> counterproductive overhead by calling for a map of size 1, is that ever
> a problem in practice? I would think the effect is undetectable.
It was easier to "ban" it as silly (an invalid option argument value)
than spend time verifying that this hand-rolled code assuming the
primality of the hash table size would hold up in this pathological
case.
Granted, I'm spending time on this thread instead... ;-)
Regards,
Branden
signature.asc
Description: PGP signature
- [PATCH] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
- [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, G. Branden Robinson, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, G. Branden Robinson, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, G. Branden Robinson, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, James K. Lowden, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n,
G. Branden Robinson <=
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, James K. Lowden, 2024/03/13
- Re: [PATCH v2] src/: ceil_prime(): Add function to get the lowest prime not smaller than n, Alejandro Colomar, 2024/03/13
[PATCH v3 2/9] [libgroff]: Remove dead code, Alejandro Colomar, 2024/03/15
[PATCH v3 3/9] src/: Remove redundant checks after strtol(3)., Alejandro Colomar, 2024/03/15
[PATCH v3 4/9] [grolbp]: Remove bogus (and redundant) check, Alejandro Colomar, 2024/03/15
[PATCH v3 0/9] strtol(3)-related fixes, Alejandro Colomar, 2024/03/15