bpo-42345: Fix hash implementation of typing.Literal (GH-23383)


Fix hash implementation of `typing.Literal`.

Update docs regarding `typing.Litaral` caching.

Base implementation was done in PR GH-23294.
(cherry picked from commit 1b54077ff6f5c1379e097e9f8e8648da9826d6ec)

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
diff --git a/Lib/typing.py b/Lib/typing.py
index 14952ec..f5316ab 100644
--- a/Lib/typing.py
+++ b/Lib/typing.py
@@ -932,7 +932,7 @@
         return set(_value_and_type_iter(self.__args__)) == set(_value_and_type_iter(other.__args__))
 
     def __hash__(self):
-        return hash(tuple(_value_and_type_iter(self.__args__)))
+        return hash(frozenset(_value_and_type_iter(self.__args__)))
 
 
 class Generic: