mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	Changed equals method on Image so it short circuits. Also put getpalette() and tobytes() comparison at the end because they are the slowest operations.
This commit is contained in:
		
							parent
							
								
									9fb00976fc
								
							
						
					
					
						commit
						53c9a80d1b
					
				
							
								
								
									
										18
									
								
								PIL/Image.py
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								PIL/Image.py
									
									
									
									
									
								
							| 
						 | 
					@ -584,16 +584,14 @@ class Image(object):
 | 
				
			||||||
        return file
 | 
					        return file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __eq__(self, other):
 | 
					    def __eq__(self, other):
 | 
				
			||||||
        if self.__class__.__name__ != other.__class__.__name__:
 | 
					        return (self.__class__.__name__ == other.__class__.__name__ and
 | 
				
			||||||
            return False
 | 
					                self.mode == other.mode and
 | 
				
			||||||
        a = (self.mode == other.mode)
 | 
					                self.size == other.size and
 | 
				
			||||||
        b = (self.size == other.size)
 | 
					                self.info == other.info and
 | 
				
			||||||
        c = (self.getpalette() == other.getpalette())
 | 
					                self.category == other.category and
 | 
				
			||||||
        d = (self.info == other.info)
 | 
					                self.readonly == other.readonly and
 | 
				
			||||||
        e = (self.category == other.category)
 | 
					                self.getpalette() == other.getpalette() and
 | 
				
			||||||
        f = (self.readonly == other.readonly)
 | 
					                self.tobytes() == other.tobytes())
 | 
				
			||||||
        g = (self.tobytes() == other.tobytes())
 | 
					 | 
				
			||||||
        return a and b and c and d and e and f and g
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __ne__(self, other):
 | 
					    def __ne__(self, other):
 | 
				
			||||||
        eq = (self == other)
 | 
					        eq = (self == other)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user