3 1353
On Jun 20, 9:38*am, Jean-Paul Calderone <exar...@divmod.comwrote:
On Fri, 20 Jun 2008 09:31:57 -0700 (PDT), michalis.avr...@gmail.com wrote:
I am not certain why this is the case, but...
>>a = 256 b = 256 a is b
True
>>a = 257 b = 257 a is b
False
Can anyone explain this further? Why does it happen? 8-bit integer
differences?
http://mail.python.org/pipermail/pyt...er/113994.html
Jean-Paul
Thank you for this Jean-Paul. I did know about the identity of
objects, but my curiosity is based on the 256 number. Are the 2^8
integers cached due to the internal loops, or is there any other
specific reason? Is this something that can be controlled? mi*************@gmail.com wrote:
On Jun 20, 9:38 am, Jean-Paul Calderone <exar...@divmod.comwrote:
>On Fri, 20 Jun 2008 09:31:57 -0700 (PDT), michalis.avr...@gmail.com wrote:
>>I am not certain why this is the case, but...
>a = 256 >b = 256 >a is b >> True
>a = 257 >b = 257 >a is b >> False
Can anyone explain this further? Why does it happen? 8-bit integer differences? http://mail.python.org/pipermail/pyt...er/113994.html
Jean-Paul
Thank you for this Jean-Paul. I did know about the identity of
objects, but my curiosity is based on the 256 number. Are the 2^8
integers cached due to the internal loops, or is there any other
specific reason? Is this something that can be controlled?
Python provides no way to change that number, but of course you can
always fiddle with the source code and recompile. The actual value is
a trade off (like any caching scheme) of cache-space versus efficiency
gains. The value has changed at least once in recent versions of Python.
Gary Herron
-- http://mail.python.org/mailman/listinfo/python-list
On Jun 21, 2:14*am, Gary Herron <gher...@islandtraining.comwrote:
michalis.avr...@gmail.com wrote:
On Jun 20, 9:38 am, Jean-Paul Calderone <exar...@divmod.comwrote:
On Fri, 20 Jun 2008 09:31:57 -0700 (PDT), michalis.avr...@gmail.com wrote:
>I am not certain why this is the case, but...
>>>>a = 256 b = 256 a is b
>True
>>>>a = 257 b = 257 a is b
>False
>Can anyone explain this further? Why does it happen? 8-bit integer differences?
>http://mail.python.org/pipermail/pyt...er/113994.html
Jean-Paul
Thank you for this Jean-Paul. I did know about the identity of
objects, but my curiosity is based on the 256 number. Are the 2^8
integers cached due to the internal loops, or is there any other
specific reason? Is this something that can be controlled?
Python provides no way to change that number, but of course you can
always fiddle with the source code and recompile. * The actual value is
a trade off (like any caching scheme) of cache-space versus efficiency
gains. * The value has changed at least once in recent versions of Python.
And if your code breaks because of this, don't whine, 'cause you've
already been warned not to rely on it. Exactly the same arguments with
other people that is/going to whine because they break the
encapsulation. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Armin Rigo |
last post by:
Hi!
This is a rant against the optimization trend of the Python interpreter.
Sorting a list of 100000 integers in random order takes:
* 0.75 seconds in Python 2.1
* 0.51 seconds in Python...
|
by: Maurice LING |
last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic
typing, is there any other real reasons that Python is slower than Java?
maurice
|
by: Wayne Sutton |
last post by:
OK, I'm a newbie...
I'm trying to learn Python & have had fun with it so far. But I'm having
trouble following the many code examples with the object "self." Can
someone explain this usage in...
|
by: Lonnie Princehouse |
last post by:
There doesn't seem to be any way to customize the behavior of "is" as
can be done for other operators... why not?
|
by: ureuffyrtu955 |
last post by:
Python is a good programming language, but "Python" is not a good
name.
First, python also means snake, Monty Python. If we search "python" in
google, emule, many results are not programming...
| |
by: michalis.avraam |
last post by:
I am not certain why this is the case, but...
True
False
Can anyone explain this further? Why does it happen? 8-bit integer
differences?
|
by: Jean-Paul Calderone |
last post by:
On Fri, 20 Jun 2008 10:07:56 -0700 (PDT), George Sakkis <george.sakkis@gmail.comwrote:
This is because using the ";" puts the statements into the same compilation
unit as each other. So secretly...
|
by: ssecorp |
last post by:
I first learned about OO from Java.
I much prefer to program in Python though.
However I am consufed about 2 things.
1. Why do I have to pass self into every method in a class? Since I am...
|
by: chenxinleo |
last post by:
Hi,
When i use some standard library functions and fields,which return
char* type(like ctime in time.h, optarg in getopt.h)and do not have to
be freed after calling,i always worry about memory...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
| |
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
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...
| |