[ 
https://issues.apache.org/jira/browse/ARROW-8131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17060833#comment-17060833
 ] 

Paul Balanca commented on ARROW-8131:
-------------------------------------

I thought at first it was a design choice in Arrow to make the inheritance hard 
(specialized builder methods {{from_*}})

My first try & intuition was in fact to go for inheritance, and your 
proposition of adding{{ ExtentionType.__arrow_ext_class__}} sounds like a 
cleaner solution than trying to dynamically add properties to every instance 
generated. Let me see if I can make it working the way you suggested.

> [Python] Add dynamic attributes to PyArrow ExtensionArray
> ---------------------------------------------------------
>
>                 Key: ARROW-8131
>                 URL: https://issues.apache.org/jira/browse/ARROW-8131
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>    Affects Versions: 0.16.0
>         Environment: Ubuntu 19.10 + Python 3.7
>            Reporter: Paul Balanca
>            Priority: Major
>              Labels: Python3, pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> In the present implementation, the interface of the class `ExtensionArray` is 
> not extendable by user. One can not easily inherit from it, as the 
> constructor __init__ can not be called directly, or it does not allow adding 
> dynamically atttributes.
> Keeping the current design with build methods `from_*`, I believe it could 
> then make sense to allow dynamic attributes in `ExtensionArray` (see 
> [https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#dynamic-attributes]).
>  The runtime & size cost of the Python objects would be fairly minimal, 
> compared to increased flexibility it would allow.
> A typical use case where it could be useful would be dynamic mixins (added by 
> custom Factory), allowing projects based on PyArrow to extend (! :)) the 
> interface with specific business logic. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to