[issue42731] Enhancement request for proxying PyString

2020-12-25 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There is no longer PyString in Python, only PyUnicode.

There are plans to get rid of PyUnicode_READY(). After removing support of 
"legacy" Unicode objects (which will happen in few years), PyUnicode_READY() 
will be no longer needed, so all calls of it could be removed. Currently there 
is a last chance to redesign it for other purposes. I suggest to discuss this 
on one of mailing lists (Python-ideas or even Python-Dev) with wider auditory, 
as it can have large impact on the future of C API.

Although I am not sure that PyUnicode_READY() is called in all needed cases. It 
just happen that the code is not tested intensively with "legacy" Unicode 
objects because in normal case you get already ready objects. Actually, 
functions like _PyUnicode_EqualToASCIIString do not call it intentionally and 
read the Py_UNICODE content of non-ready Unicode objects directly.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42731] Enhancement request for proxying PyString

2020-12-24 Thread Karl Nelson


New submission from Karl Nelson :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com