syun64 commented on issue #751: URL: https://github.com/apache/iceberg-python/issues/751#issuecomment-2189578278
> @syun64 when debugging or printing the key variable in the Singleton class you will see that when we initialize the class we have the arguments, but when the deepcopy occurs we don't have. > > > > Example with printing the arguments > > ```python > > (<class 'pyiceberg.types.FixedType'>, (8,), ()) <- Initialization > > (<class 'pyiceberg.types.FixedType'>, (16,), ()) <- Initialization > > (<class 'pyiceberg.types.FixedType'>, (), ()) <- deep copy > > (<class 'pyiceberg.types.FixedType'>, (), ()) <- deep copy > > ``` > > > > printing the instances > > ```python > > key (<class 'pyiceberg.types.FixedType'>, (8,), ()) > > instances {} > > key (<class 'pyiceberg.types.FixedType'>, (16,), ()) > > instances {(<class 'pyiceberg.types.FixedType'>, (8,), ()): FixedType(length=8)} > > key (<class 'pyiceberg.types.FixedType'>, (), ()) > > instances {(<class 'pyiceberg.types.FixedType'>, (8,), ()): FixedType(length=8), (<class 'pyiceberg.types.FixedType'>, (16,), ()): FixedType(length=16)} > > key (<class 'pyiceberg.types.FixedType'>, (), ()) > > instances {(<class 'pyiceberg.types.FixedType'>, (8,), ()): FixedType(length=8), (<class 'pyiceberg.types.FixedType'>, (16,), ()): FixedType(length=16), (<class 'pyiceberg.types.FixedType'>, (), ()): FixedType(length=8)} > > ``` This is so helpful @ndrluis - thank you for sharing this! My knowledge of how deep copy exactly works is a bit limited, but I wonder if we can override this behavior somehow. If that's not possible, I think we will have to consider one of the two following options: 1. Find a way to selectively avoid deep copying (and instead just copy) certain classes - since the Singleton classes cannot be deep copied anyways, we should be okay keeping the previous object reference on the deep copied TableMetadata 2. As @kevinjqliu already suggested, don't inherit from the Singleton class for these multi argument classes. My preference is for option (1) - would it be possible to override __deepcopy__ of the Singleton class to invoke copy instead? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org