Skip to content

Instantly share code, notes, and snippets.

View sterliakov's full-sized avatar

Stanislav Terliakov sterliakov

View GitHub Profile
@sterliakov
sterliakov / botocore-s3-service.json
Created May 23, 2023 00:53
Patched service definition
{
"version":"2.0",
"metadata":{
"apiVersion":"2006-03-01",
"checksumFormat":"md5",
"endpointPrefix":"s3",
"globalEndpoint":"s3.amazonaws.com",
"protocol":"rest-xml",
"serviceAbbreviation":"Amazon S3",
"serviceFullName":"Amazon Simple Storage Service",
@sterliakov
sterliakov / hashable_mutable.py
Created July 23, 2022 00:14
Example of unexpected results with mutable hashable objects
class MyDict(dict):
def __hash__(self):
return hash(frozenset(self))
key = MyDict(a=1)
mapping = {key: 'foo'}
key['b'] = 2
mapping[key] # KeyError: {'a': 1, 'b': 2}
# Do you expect that variable which you have added to dict would raise KeyError?