[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Cost of "unicode(s)" where s is Unicode

John Nagle

1/6/2008 4:07:00 PM

Does

text = unicode(text)

make a copy of a Unicode string, or is that essentially a
free operation if the input is already Unicode?

John Nagle
5 Answers

Rob Williscroft

1/6/2008 4:08:00 PM

0

John Nagle wrote in news:4780fb68$0$36341$742ec2ed@news.sonic.net in
comp.lang.python:

> Does
>
> text = unicode(text)
>
> make a copy of a Unicode string, or is that essentially a
> free operation if the input is already Unicode?
>
> John Nagle
>

http://docs.python.org/lib/built-in-funcs.h...

... More precisely, if object is a Unicode string or subclass it
will return that Unicode string without any additional decoding
applied.
...


Rob.
--
http://www.victim-prime.dsl....

Christian Heimes

1/6/2008 4:14:00 PM

0

John Nagle wrote:
> Does
>
> text = unicode(text)
>
> make a copy of a Unicode string, or is that essentially a
> free operation if the input is already Unicode?

>>> u = u"some long unicode object"
>>> unicode(u) is u
True

Christian Heimes

1/6/2008 4:14:00 PM

0

John Nagle wrote:
> Does
>
> text = unicode(text)
>
> make a copy of a Unicode string, or is that essentially a
> free operation if the input is already Unicode?

>>> u = u"some long unicode object"
>>> unicode(u) is u
True

JKPeck

1/6/2008 4:22:00 PM

0

On Jan 6, 9:06 am, John Nagle <na...@animats.com> wrote:
> Does
>
> text = unicode(text)
>
> make a copy of a Unicode string, or is that essentially a
> free operation if the input is already Unicode?
>
> John Nagle

>>> u = u"abc"
>>> uu = unicode(u)
>>> u is uu
True
>>> s = "abc"
>>> ss = unicode(s)
>>> s is ss
False

HTH,
Jon Peck

aahz

1/6/2008 5:53:00 PM

0

In article <70b9f250-a7b5-423e-8395-d0c4215d2564@d70g2000hsb.googlegroups.com>,
JKPeck <JKPeck@gmail.com> wrote:
>
>>>> u = u"abc"
>>>> uu = unicode(u)
>>>> u is uu
>True
>>>> s = "abc"
>>>> ss = unicode(s)
>>>> s is ss
>False

You uuencode Unicode?
--
Aahz (aahz@pythoncraft.com) <*> http://www.python...

Sorry, couldn't resist the alliteration