New submission from Karl Nelson <nelso...@llnl.gov>:

When developing with JPype, the largest hole currently is that Java returns a 
string type which cannot be represented as a str.  Java strings are string like 
and immutable and can be pulled to Python when needed, but it is best if they 
remain in Java until Python requests it as pulling all string values through 
the API and pushing them back can result in serious overhead.  Thus they need 
to be represented as a Proxy to a string, which can be accessed as a string at 
anytime.

Throughout the Python API str is treated as a concrete type (though it is 
somewhat polymorphic due to different storage for code points sizes.)  There is 
also handling for an "unready" string which needs additional treatment before 
it can be accessed.  Unfortunately this does not appear to be suitable for 
creating a proxy object which can be pulled from another source to create a 
string on demand.   Having a "__str__()" method is insufficient as that merely 
makes an object able to become a string rather than considered to be a string 
by the rest of the API.

Would it be possible to generalize the concept of an unready string so that 
when Ready is called it fetches the actually string contents, creates a piece 
of memory to store the string contents (outside of the object itself), and sets 
the access flags for so that the code points can be interpreted?   Is this 
already possible in the API?  Are there any other plans to make the str type 
able to operate as a proxy?

----------
components: Extension Modules
messages: 383701
nosy: Thrameos
priority: normal
severity: normal
status: open
title: Enhancement request for proxying PyString
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42731>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to