By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,220 Members | 1,091 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,220 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jan 6 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
John Nagle wrote in news:47***********************@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.html#l2h-78

... 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.pipex.com/
Jan 6 '08 #2

P: n/a
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
Jan 6 '08 #3

P: n/a
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

Jan 6 '08 #4

P: n/a
On Jan 6, 9:06 am, John Nagle <na...@animats.comwrote:
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
Jan 6 '08 #5

P: n/a
In article <70**********************************@d70g2000hsb. googlegroups.com>,
JKPeck <JK****@gmail.comwrote:
>
>>>u = u"abc"
uu = unicode(u)
u is uu
True
>>>s = "abc"
ss = unicode(s)
s is ss
False
You uuencode Unicode?
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

Sorry, couldn't resist the alliteration
Jan 6 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.