[New-bugs-announce] [issue42731] Enhancement request for proxying PyString

Karl Nelson report at bugs.python.org
Thu Dec 24 14:13:42 EST 2020


New submission from Karl Nelson <nelson85 at 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 <report at bugs.python.org>
<https://bugs.python.org/issue42731>
_______________________________________


More information about the New-bugs-announce mailing list