[Patches] [Patch #101664] Add new unistr() builtin + PyObject_Unicode() C API

noreply@sourceforge.net noreply@sourceforge.net
Wed, 17 Jan 2001 09:09:16 -0800


Patch #101664 has been updated. 

Project: python
Category: core (C code)
Status: Closed
Submitted by: lemburg
Assigned to : lemburg
Summary: Add new unistr() builtin + PyObject_Unicode() C API

Follow-Ups:

Date: 2001-Jan-17 09:09
By: lemburg

Comment:
Checked in.
-------------------------------------------------------

Date: 2001-Jan-17 07:43
By: gvanrossum

Comment:
Go ahead and check it in, Marc!

-------------------------------------------------------

Date: 2000-Sep-26 04:14
By: lemburg

Comment:
This patch adds a utility function unistr() which works just like
the standard builtin str()  -- only that the return value will
always be a Unicode object.

The patch also adds a new object level C API PyObject_Unicode()
which complements PyObject_Str().

Since this is a new feature, I have postponed the patch to be reopened
in the 2.1 cycle.

-------------------------------------------------------

Date: 2000-Oct-30 06:44
By: moshez

Comment:
There is no documentation for unistr() and PyObject_Unicode(), which is
usually considered a show stopper by the powers that be.

Here's some draft docos

Insert into Doc/libfuncs.tex, after
\begin{funcdesc}{str}....\end{funcdesc}:
\begin{funcdesc}{unistr}{object}
Return a Unicode representation of an object.
It returns the result of converting the str(object) to unicode if the
object can be converted into a string. It returns unicode objects as is.
\end{funcdesc}

Insert the following in Doc/api/api.tex after
\begin{cfuncdesc}{PyObject*}{PyObject_Str}{PyObject *o}...\end{cfuncdesc}

\begin{cfuncdesc}{PyObject *}{PyObject_Unicode}{PyObject *O}
Compute a unicode representation of  \var{o}. Returns the unicode
representation on success \NULL{} on failure. This is the equivalent
of the Python expression \samp{unistr(\var{o})}.
Called by the \function{unistr()}\bifuncindex{unistr} built-in function.
\end{cfuncdesc}
Oh, and please don't use PyObject_GetAttrString: It's slow....
-------------------------------------------------------

Date: 2000-Oct-30 07:19
By: nobody

Comment:
Thanks. I'll add the docs to the patch.

About PyObject_GetAttrString() ... I'll add an optimization somewhat
like in classobject.c to PyObject_Unicode() which should help
boost the performance somewhat.

-------------------------------------------------------

-------------------------------------------------------
For more info, visit:

http://sourceforge.net/patch/?func=detailpatch&patch_id=101664&group_id=5470