Hey James,

The latter approach sounds fine. You could actually refactor the bit that wraps 
the Python object in a C++ middleware instance[1] into a cdef method onto the 
interface. Then the native-C++ middleware could override it and return the C++ 
object directly and the Python implementations would continue to do the 
wrapping.

Best,
David

[1]: 
https://github.com/apache/arrow/blob/b00325bd98d01e43fb0d0b99effeb0d1d0d0fe16/python/pyarrow/_flight.pyx#L1070-L1072

On Mon, Nov 16, 2020, at 13:33, James Duong wrote:
> Hi,
> 
> I've been working on porting the cookie middleware from Java to C++/Python
> clients in this PR:
> https://github.com/apache/arrow/pull/8655
> 
> I'm looking at the Python impl now. The Python Flight API for middlewares
> seems
> oriented towards writing middlewares directly in Python, which would get
> wrapped
> in a C++ middleware for running Python code.
> 
> It seems to me like there are two solutions for this:
> 1. Creating some helper static function in Python which takes a C++
> middleware
> pointer and wraps it in a Python middleware, which in turn would get
> wrapped in
> a C++ middleware again in the C++ layer.
> 2. Expose the concept of letting the Python client accept 'pass-through'
> middleware
> objects that don't implement the Python interface, and are interpreted by
> the C++
> layer to be direct C++ middleware objects.
> 
> The former seems like a better of abstraction and seems like the way to go,
> although less efficient. The latter is obviously less convoluted, but
> brings up issues if we ever change the Python implementation from being a
> wrapper around C++.
> 
> -- 
> 
> *James Duong*
> Lead Software Developer
> Bit Quill Technologies Inc.
> Direct: +1.604.562.6082 | jam...@bitquilltech.com
> https://www.bitquilltech.com
> 
> This email message is for the sole use of the intended recipient(s) and may
> contain confidential and privileged information.  Any unauthorized review,
> use, disclosure, or distribution is prohibited.  If you are not the
> intended recipient, please contact the sender by reply email and destroy
> all copies of the original message.  Thank you.
> 

Reply via email to