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.robin...@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