An unhashable type list is a list that can’t be turned into a hash table.
Hash tables are arrays that have been converted to strings, and then hashed with an algorithm. Algorithms have been created specifically for certain types of data, such as word lists and people who like pizza on Facebook.
But what happens when you want to create a hash table out of something new and different… like your favorite movie?
If you don’t know the hashing algorithm for movies — or worse — if there isn’t one, then it’s impossible to make a hash table out of your favorite movie!
This is why sometimes new data must be stored as an array instead of as a hash table.
There are a number of approaches to solving this problem.
You could use a hash function in the code, but that means the code would have to be maintained, and if it changed, you’d have to provide an updated function.
Or the programmer could copy the actual data into an array and then modify that array later, which can lead to numerous problems when multiple programmers change it at the same time. So there’s no way to solve this problem with code.
Furthermore… Despite being called a hash table, a hash table is not really a form of data storage! It’s really just a way of converting one type of data into another with a little bit of calculation on top.
Hashing is a method involving a lot of calculation, so it’s not clear if one could use a hash table to store data in another type of storage.
Information about unhashable type list :
1. Of course, a list is a type. What’s “unhashable” about it?
Lists are data structures. That is, they’re capable of containing other data structures. In fact, they’re as much a data structure as arrays or trees or linked lists.
Lists are also capable of storing their own data structure!
What does it mean for a list to be “unhashable”?
That is, in addition to being a list and storing other lists in them, lists can store other data types — such as integers or strings — in them.
So why would we expect them not to be hashable? These things aren’t unhashable because they’re incapable of performing hash functions on their own.
They’re capable of performing hash functions. It’s just that to do so, they need another piece of code that does the work, and that code likely isn’t maintained!
2.Unhashable type list is a list that cannot be turned into a hash table.
In other words, the word “unhashable” doesn’t refer to whether or not a type can be hashed. Rather, it refers to whether or not the list itself can be hashed.
In practice, this means that you can’t turn an unhashable type list into a hash table. In other words, you can’t turn an unhashable type list into a hash table.
I suspect that this article was written by someone who can’t read. This should be made into a lolcat image.
3. Why, then, is it called a hash table?
What’s the relationship between the two?
The word “hash table” refers to the array itself, not to the data contained in it or to any code used for hashing!
This means that calling a list hashable or unhashable while discussing it using the words “hash table” could lead to some confusion!
The confusion is precisely this: if we call a list an unhashable type list because it cannot be turned into a hash table… How can it be called a hash table? It sounds like an oxymoron.
But even this mess isn’t the end of the confusion!
If a list is called a hash table because it can be turned into a hash table, then mustn’t it be called a hash table even if its only purpose is to contain other lists?
It becomes hard to say what a word means when all sides of the debate are trying to use it interchangeably!
So who’s right? Is this an argument about lists? Or is it an argument about lists and tables?
4. Can you make a “hashable type list”?
You can convert any type into an unhashable type list!
There are all sorts of lists that are hashable, including arrays, linked lists, and even functions! It’s just that they’re not always useful as hashes.
For example, if you have a function that is linked to some random data in your code… you wouldn’t want to use the code as a hash function for your data types. So please please please! Please do not call this article “Unhashables”.