473,692 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
5 1244
John Nagle wrote in news:47******** *************** @news.sonic.net in
comp.lang.pytho n:
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
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
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
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
In article <70************ *************** *******@d70g200 0hsb.googlegrou ps.com>,
JKPeck <JK****@gmail.c omwrote:
>
>>>u = u"abc"
uu = unicode(u)
u is uu
True
>>>s = "abc"
ss = unicode(s)
s is ss
False
You uuencode Unicode?
--
Aahz (aa**@pythoncra ft.com) <* http://www.pythoncraft.com/

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1368
by: Petr Prikryl | last post by:
Hi all, My question is: How do you tackle with mixing Unicode and non-Unicode parts of your application? Context: ======== The PEP 3000 says "Make all strings be Unicode, and have a separate bytes() type."
2
5698
by: Bruce | last post by:
I am trying to compile my project but it is compiling for Unicode. I checked the preprocessor definitions and there is no UNICODE reference but I see /D "_UNICODE" /D "UNICODE" in the command line. I even tried clearing all of the preprocessor definitions and the /D "_UNICODE" /D "UNICODE" entry in the command line still remain. How do I clear this?
1
2580
by: NevilleDNZ | last post by:
Hi, Apologies first as I am not a unicode expert.... indeed I the details probably totally elude me. Not withstanding: how can I convert a binary string containing UTF-8 binary into a python unicode string? cutdown example: $ cat ./uc.py #!/usr/bin/env python imported="\304\246\311\231\316\257\316\271\303\222
3
7072
by: MIUSS | last post by:
Hello everyone! I got a problem with creating new line... I tried this: lstrcpy(NewLineIdr, TEXT("\r\n")); I already tried this: NewLineIdr = 0x000D; NewLineIdr = 0x000A; NewLineIdr = 0x0000; I need it to use it in my saving procedure because I need to create tabullary text file. But my effort usually results in one or two small
0
8548
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9090
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8970
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8813
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7641
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6462
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2989
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.