Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #196978
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | dn <PythonList@DancesWithMice.info> |
| Newsgroups | comp.lang.python |
| Subject | Re: Two aces up Python's sleeve |
| Date | Fri, 8 Nov 2024 13:07:48 +1300 |
| Organization | DWM |
| Lines | 61 |
| Message-ID | <mailman.87.1731024481.4695.python-list@python.org> (permalink) |
| References | <seven-20241106014329@ram.dialup.fu-berlin.de> <vgg5dn$ij48$1@solani.org> <050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green> <vgihe5$9tsc$1@solani.org> <lp4sgdFg90oU1@mid.individual.net> <0c94311a-f3e4-4aac-93e8-9bf95c065dcf@DancesWithMice.info> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de z00KZoEboE6Apow70GFSCQ2upNZeyq0zTLQ9vktz60FQ== |
| Cancel-Lock | sha1:o+QCNzq1XyldtWeWKNTkL96Skes= sha256:qtz2CmbeO/WmkMCr/q5aTeJOh2pEC15nrG+CbWbw/3o= |
| Return-Path | <PythonList@DancesWithMice.info> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| Authentication-Results | mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=danceswithmice.info header.i=@danceswithmice.info header.b=enOUZecE; dkim-adsp=pass; dkim-atps=neutral |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '=dn': 0.09; 'compiler': 0.09; 'computing': 0.09; 'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist': 0.09; 'hat': 0.09; 'linux': 0.09; 'newsgroup': 0.09; 'shock': 0.09; 'subject:Python': 0.12; 'constant': 0.16; 'forever.': 0.16; 'greg': 0.16; 'indeed': 0.16; 'integer': 0.16; 'message-id:@DancesWithMice.info': 0.16; 'pointers': 0.16; 'print(': 0.16; 'received:51.254': 0.16; 'received:51.254.211': 0.16; 'received:51.254.211.219': 0.16; 'received:cloud': 0.16; 'received:rangi.cloud': 0.16; 'think.': 0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20; 'run': 0.23; 'actual': 0.25; 'else': 0.27; '>>>': 0.28; 'header :User-Agent:1': 0.30; 'am,': 0.31; '254': 0.32; 'guess': 0.32; 'python-list': 0.32; 'header:Organization:1': 0.32; 'hold': 0.33; 'header:In-Reply-To:1': 0.34; "it's": 0.37; 'could': 0.37; 'received:192.168': 0.37; 'url-ip:151.101.0.223/32': 0.38; 'url- ip:151.101.128.223/32': 0.38; 'url-ip:151.101.192.223/32': 0.38; 'url-ip:151.101.64.223/32': 0.38; 'this,': 0.39; 'valid': 0.39; 'decide': 0.39; 'forwarding': 0.40; 'something': 0.40; 'seen': 0.62; 'skip:i 20': 0.62; 'range': 0.64; 'received:51': 0.64; 'thus': 0.64; 'time.': 0.66; 'numbers': 0.67; 'guaranteed': 0.67; '1000': 0.70; '....': 0.76; 'btw': 0.84 |
| DKIM-Filter | OpenDKIM Filter v2.11.0 vps.rangi.cloud 3540A7FF5 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info; s=staff; t=1731024472; bh=1Ike7doebtO7zHIF4pkbc1GfRuaq5lI6T2O6bL3gkm0=; h=Date:From:Subject:To:References:In-Reply-To:From; b=enOUZecEDZ/yf9W3ZUI/2TePxyX2uQq19JDahEgC9l60X4Q4mRuQ042o/EgnddkEq ISSoso28bIkadTqnUZ6mjUcGXYoe6kXvDZsaYTB4jfaRkprmAakXbGvAxRnVLMWhCA jSWuHUTbIReQ1IWX0E9i70MSLeBEISGis+wnRyrU4ocjqXLlMNC37C4ETOaQexjhyo X8m5n8RRkH3VeQZM2GT/jEBuiRrLF3OkzO5k0L7WxhqFD9Dg3RaDyN7cOjuwyKBSZ1 BcpMZAySv5eVd1JjLK3DbxKPXcDgC7K8xqSv/5anH7UqvGMSgF/8rcnCewOl6iZz+K Z+lwIWANGWKVQ== |
| User-Agent | Mozilla Thunderbird |
| Content-Language | en-US |
| In-Reply-To | <lp4sgdFg90oU1@mid.individual.net> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.39 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <https://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <0c94311a-f3e4-4aac-93e8-9bf95c065dcf@DancesWithMice.info> |
| X-Mailman-Original-References | <seven-20241106014329@ram.dialup.fu-berlin.de> <vgg5dn$ij48$1@solani.org> <050c2ce9efd8442fb902ecc926afb1ee42fe6c34.camel@tilde.green> <vgihe5$9tsc$1@solani.org> <lp4sgdFg90oU1@mid.individual.net> |
| Xref | csiph.com comp.lang.python:196978 |
Show key headers only | View raw
On 8/11/24 11:15, Greg Ewing via Python-list wrote:
> On 8/11/24 3:04 am, Mild Shock wrote:
>> This only works for small integers. I guess
>> this is because tagged pointers are used
>> nowadays ?
>
> No, it's because integers in a certain small range are cached. Not sure
> what the actual range is nowadays, it used to be something like -5 to
> 256 I think.
>
> BTW you have to be careful testing this, because the compiler sometimes
> does constant folding, so you need to be sure it's actually computing
> the numbers at run time.
Haven't seen the OP. Is the Newsgroup link forwarding to the email-list
correctly?
Integer interning is indeed valid for -5 <= i <= 256
("it works on my machine"! see below)
>>> a = 0; b = 0; c = 0; d = 0
>>> while a is b:
... print( a, b, end=" ", )
... print( c, d, ) if c is d else print()
... a += 1; b += 1; c -= 1; d -= 1
...
0 0 0 0
1 1 -1 -1
2 2 -2 -2
3 3 -3 -3
4 4 -4 -4
5 5 -5 -5
6 6
7 7
8 8
9 9
...
254 254
255 255
256 256
>>>
Be aware that this is implementation-dependent and not guaranteed to
hold forever.
dn ~ python
Python 3.12.7 (main, Oct 1 2024, 00:00:00) [GCC 13.3.1 20240913 (Red
Hat 13.3.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
See also https://docs.python.org/3/library/sys.html#sys.intern
Thus could decide what is interned for yourself:
a_string = sys.intern( str( 1000 ) )
--
Regards,
=dn
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-06 17:27 +0100
Re: Two aces up Python's sleeve Annada Behera <annada@tilde.green> - 2024-11-07 12:55 +0530
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-07 15:04 +0100
Re: Two aces up Python's sleeve Greg Ewing <greg.ewing@canterbury.ac.nz> - 2024-11-08 11:15 +1300
Re: Two aces up Python's sleeve dn <PythonList@DancesWithMice.info> - 2024-11-08 13:07 +1300
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:25 +0100
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:29 +0100
Re: Two aces up Python's sleeve Mild Shock <janburse@fastmail.fm> - 2024-11-08 01:47 +0100
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-11-08 01:10 +0000
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Mild Shock <janburse@fastmail.fm> - 2024-11-08 02:40 +0100
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) dn <PythonList@DancesWithMice.info> - 2024-11-09 08:09 +1300
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Mild Shock <janburse@fastmail.fm> - 2024-11-08 20:49 +0100
Re: Two aces up Python's sleeve (Posting On Python-List Prohibited) Thomas Passin <list1@tompassin.net> - 2024-11-08 17:00 -0500
csiph-web