(self, prefix, ctx, item_to_hash)
Generates name of variable to be used in the generated code. This
        also ensures that same items_to_hash will yield same names.
Generates name of variable to be used in the generated code. This
        also ensures that same items_to_hash will yield same names.
Generates name of variable to be used in the generated code . This also ensures that same items_to_hash will yield same names .
def gen_name(self, prefix, ctx, item_to_hash) -> str:
        """Generates name of variable to be used in the generated code. This
        also ensures that same items_to_hash will yield same names."""
        prefixed_hash_to_name = ctx[self.PREFIXED_HASH_TO_NAME]
        generated_names = ctx[self.GENERATED_NAMES]
        try:
            prefixed_hash = (prefix, item_to_hash)
            if prefixed_hash in prefixed_hash_to_name:
                return prefixed_hash_to_name[prefixed_hash]
        except TypeError:
            prefixed_hash = (prefix, id(item_to_hash))
            if prefixed_hash in prefixed_hash_to_name:
                return prefixed_hash_to_name[prefixed_hash]

        name = prefix
        for _ in range(10):
            name += (
                f"_{choice(self.allowed_symbols)}"
                f"{choice(self.allowed_symbols)}"
            )
            if name not in generated_names:
                prefixed_hash_to_name[prefixed_hash] = name
                generated_names.add(name)
                return name
        raise AssertionError("failed to generate unique filename", name)
def gen_name ( self , prefix , ctx , item_to_hash ) -> str : prefixed_hash_to_name = ctx [ self . PREFIXED_HASH_TO_NAME ] generated_names = ctx [ self . GENERATED_NAMES ] try : prefixed_hash = ( prefix , item_to_hash ) if prefixed_hash in prefixed_hash_to_name : return prefixed_hash_to_name [ prefixed_hash ] except TypeError : prefixed_hash = ( prefix , id ( item_to_hash ) ) if prefixed_hash in prefixed_hash_to_name : return prefixed_hash_to_name [ prefixed_hash ] name = prefix for _ in range ( 10 ) : name += ( f"_{choice(self.allowed_symbols)}" f"{choice(self.allowed_symbols)}" ) if name not in generated_names : prefixed_hash_to_name [ prefixed_hash ] = name generated_names . add ( name ) return name raise AssertionError ( "failed to generate unique filename" , name )