vyasr commented on issue #38325:
URL: https://github.com/apache/arrow/issues/38325#issuecomment-2046230748

   While I agree that supporting a version attribute is more work, it also 
feels more natural than introspecting an API to determine what is supported. If 
I read code relying on signature inspection I assume it's doing something 
fairly hacky by default (which isn't to say that I haven't written such code on 
multiple occasions before...).
   
   If we don't want versioning, another option (that I'm not necessarily a huge 
fan of but is worth considering) is defining the protocol as a function that 
accepts arbitrary keyword arguments `obj.__arrow_device_array__(**kwargs)`. 
Then producers can choose what arguments to support. We could allow consumers 
to opt out (or opt in) to error-handling:
   ```
   class Foo:
       def __arrow_device_array__(self, *, strict=True, **kwargs):
           try:
               parse_kwargs(kwargs)
           except BaseException as e:
               if strict:
                   raise
               else:
                   warn_about_unsupported_kwargs(kwargs, e)
   ````
   
   This way all options are only honored if they are supported. Otherwise, it's 
up to the consumer if they want this to fail loudly or if they want to handle 
things themselves. 
   
   One downside of this approach is that it assumes that consumers are fine 
stating the superset of all options that they want and then accepting whether 
or not producers will honor those options. If consumers want to dynamically 
adjust the calls based on the options available from a particular producer, 
they will have to resort to doing so more manually (e.g. via `isinstance` 
checks that sort of defeat the purpose of a protocol). It also precludes the 
signature-based introspection.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to