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

Discussion in 'Python' started by John Nagle, Jan 6, 2008.

  1. John Nagle

    John Nagle Guest

    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
     
    John Nagle, Jan 6, 2008
    #1
    1. Advertising

  2. John Nagle wrote in news:4780fb68$0$36341$ 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/
     
    Rob Williscroft, Jan 6, 2008
    #2
    1. Advertising

  3. 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, Jan 6, 2008
    #3
  4. 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, Jan 6, 2008
    #4
  5. John Nagle

    JKPeck Guest

    On Jan 6, 9:06 am, 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?
    >
    > John Nagle


    >>> u = u"abc"
    >>> uu = unicode(u)
    >>> u is uu

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

    False

    HTH,
    Jon Peck
     
    JKPeck, Jan 6, 2008
    #5
  6. John Nagle

    Aahz Guest

    In article <>,
    JKPeck <> wrote:
    >
    >>>> u = u"abc"
    >>>> uu = unicode(u)
    >>>> u is uu

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

    >False


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

    Sorry, couldn't resist the alliteration
     
    Aahz, Jan 6, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brendan Lynskey

    Low-cost ASIC tools

    Brendan Lynskey, Sep 26, 2003, in forum: VHDL
    Replies:
    2
    Views:
    2,090
    Jerry
    Sep 27, 2003
  2. Mr. x

    cost of SSL on the client

    Mr. x, Dec 2, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    364
    Mr. x
    Dec 3, 2003
  3. Ali

    Cost for using Server control

    Ali, Dec 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    324
    Jason S
    Dec 5, 2003
  4. msn
    Replies:
    9
    Views:
    352
  5. John Bailo

    Cost of web.config parameters

    John Bailo, Apr 14, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    431
    John Bailo
    Apr 15, 2004
Loading...

Share This Page