mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-04 07:51:21 +00:00 
			
		
		
		
	utils/misc: memoized: fix kwarg IDs
Use __get_memo_id() for keyword arguments, rather than stringifying them. The has somewhat lower chance of producing the same identifier for two conceptually unequal objects.
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							a3c04fc140
						
					
				
				
					commit
					bdaea26f6f
				
			@@ -661,7 +661,7 @@ def memoized(wrapped, instance, args, kwargs):  # pylint: disable=unused-argumen
 | 
			
		||||
 | 
			
		||||
    def memoize_wrapper(*args, **kwargs):
 | 
			
		||||
        id_string = func_id + ','.join([__get_memo_id(a) for a in  args])
 | 
			
		||||
        id_string += ','.join('{}={}'.format(k, v)
 | 
			
		||||
        id_string += ','.join('{}={}'.format(k, __get_memo_id(v))
 | 
			
		||||
                              for k, v in kwargs.items())
 | 
			
		||||
        if id_string not in __memo_cache:
 | 
			
		||||
            __memo_cache[id_string] = wrapped(*args, **kwargs)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user