Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45542

Re: mutable ints: I think I have painted myself into a corner

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'method.': 0.07; 'modify': 0.07; 'subject:into': 0.09; 'toss': 0.09; 'cc:addr:python-list': 0.11; '"an': 0.16; '_do_': 0.16; 'bitwise': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'math,': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subclass': 0.16; 'those,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'all,': 0.19; 'else,': 0.19; 'addition,': 0.20; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'header:User- Agent:1': 0.23; 'decide': 0.24; 'cheers,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'chris': 0.29; 'am,': 0.29; "doesn't": 0.30; 'bigger': 0.30; 'easier': 0.31; '(possibly': 0.31; 'flags': 0.31; 'int,': 0.31; 'ordinary': 0.31; 'anyone': 0.31; 'interface': 0.32; 'something': 0.35; 'operate': 0.35; 'but': 0.35; 'there': 0.35; 'are,': 0.36; 'received:com.au': 0.36; 'doing': 0.36; 'method': 0.36; 'charset:us-ascii': 0.36; 'example,': 0.37; 'seconds': 0.37; 'wrong': 0.37; 'mapping': 0.38; 'received:211': 0.38; 'that,': 0.38; 'does': 0.39; 'functional': 0.39; 'skip:u 10': 0.60; 'most': 0.60; 'break': 0.61; 'back': 0.62; 'content-disposition:inline': 0.62; 'places': 0.64; 'more': 0.64; 'forward': 0.65; '(that': 0.65; 'to:addr:gmail.com': 0.65; 'started.': 0.68; 'hoping': 0.75; 'subject:have': 0.80; 'bitmap': 0.84; 'exterior': 0.84; 'precious': 0.84; 'subject:think': 0.84; 'imagine': 0.93; '2013': 0.98
Date Sun, 19 May 2013 11:54:04 +1000
From Cameron Simpson <cs@zip.com.au>
To Chris Angelico <rosuav@gmail.com>
Subject Re: mutable ints: I think I have painted myself into a corner
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <CAPTjJmrgFGP=4pHXN7cKRzZ4pNg1Yeki=iPFw9bRLDF-osYAaA@mail.gmail.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <CAPTjJmrgFGP=4pHXN7cKRzZ4pNg1Yeki=iPFw9bRLDF-osYAaA@mail.gmail.com>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.0 cv=e/de0tV/ c=1 sm=1 a=wom5GMh1gUkA:10 a=21x4_w1R3MUA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=StZfE6sK-9QA:10 a=pGLkceISAAAA:8 a=cexIBkohAAAA:8 a=mfKAelKGM9Gr3oEjTaIA:9 a=CjuIK1q_8ugA:10 a=MSl-tDqOz04A:10 a=ChdAjXE5lkUvdteQbhpnkQ==:117
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1828.1368928471.3114.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368928471 news.xs4all.nl 15940 [2001:888:2000:d::a6]:46523
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45542

Show key headers only | View raw


On 19May2013 11:11, Chris Angelico <rosuav@gmail.com> wrote:
| On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson <cs@zip.com.au> wrote:
| > Before I toss this approach and retreat to my former "object"
| > technique, does anyone see a way forward to modify an int subclass
| > instance in place? (That doesn't break math, preferably; I don't
| > do arithmetic with these things but they are, after all, ints...)
| 
| Why is it an int subclass? Because there are places where you want to
| use it as though it were an int? It might be easier to render those,
| instead, eg by creating a __int__ method. (Or is it "an __int__
| method"? Not sure.)

I don't want to use it as an int, on the outside. I want to use an
int on the inside as the implementation.

It's an int _subclass_ so that it is no bigger than an int. Otherwise
I may as well just make an ordinary object and be back where I
started.  Bulky:-(

The reason it is an _int_ subclass, versus something else, is that
a bitmap is a type of int. So the functional mapping is direct.

I _do_ _not_ want to operate on it from the outside as an int (doing
overt addition, for example, though I can imagine doing bitwise
activities); I want to operate on in _internally_ as a int to decide
what names-by-an-attribute flags are on or off.

So an object with an __int__() method is right out; it's the wrong
interface because it would mean an int() call (possibly implicit)
in exterior code.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

Hoping to shave precious seconds off the time it would take me to get
through the checkout process and on my way home, I opted for the express
line ("9 Items Or Less [sic]"  Why nine items?  Where do they come up with
these rules, anyway?  It's the same way at most stores -- always some
oddball number like that, instead of a more understandable multiple of
five.  Like "five.")
        - Geoff Miller, geoffm@purplehaze.Corp.Sun.COM

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: mutable ints: I think I have painted myself into a corner Cameron Simpson <cs@zip.com.au> - 2013-05-19 11:54 +1000
  Re: mutable ints: I think I have painted myself into a corner Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-05-20 13:23 +1200
    Re: mutable ints: I think I have painted myself into a corner Cameron Simpson <cs@zip.com.au> - 2013-05-20 16:07 +1000

csiph-web