Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Cost of "unicode(s)" where s is Unicode

Reply
Thread Tools

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

 
 
John Nagle
Guest
Posts: n/a
 
      01-06-2008
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
 
Reply With Quote
 
 
 
 
Rob Williscroft
Guest
Posts: n/a
 
      01-06-2008
John Nagle wrote in news:4780fb68$0$36341$(E-Mail Removed) 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/
 
Reply With Quote
 
 
 
 
Christian Heimes
Guest
Posts: n/a
 
      01-06-2008
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
 
Reply With Quote
 
Christian Heimes
Guest
Posts: n/a
 
      01-06-2008
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

 
Reply With Quote
 
JKPeck
Guest
Posts: n/a
 
      01-06-2008
On Jan 6, 9:06 am, John Nagle <(E-Mail Removed)> 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
 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      01-06-2008
In article <(E-Mail Removed)>,
JKPeck <(E-Mail Removed)> wrote:
>
>>>> u = u"abc"
>>>> uu = unicode(u)
>>>> u is uu

>True
>>>> s = "abc"
>>>> ss = unicode(s)
>>>> s is ss

>False


You uuencode Unicode?
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

Sorry, couldn't resist the alliteration
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.lisdir, gets unicode, returns unicode... USUALLY?!?!? gabor Python 13 11-18-2006 09:23 AM
Unicode digit to unicode string Gabriele *darkbard* Farina Python 2 05-16-2006 01:15 PM
unicode wrap unicode object? ygao Python 6 04-08-2006 09:54 AM
NZ Cost vs US Cost... news.xtra.co.nz NZ Computing 14 01-05-2006 01:03 PM
Unicode + jsp + mysql + tomcat = unicode still not displaying Robert Mark Bram Java 0 09-28-2003 05:37 AM



Advertisments