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

2013-05-20 Thread Cameron Simpson
On 19May2013 09:01, Peter Otten __pete...@web.de wrote: | Cameron Simpson wrote: | | TL;DR: I think I want to modify an int value in place. | | Yesterday I was thinking about various flag set objects I have | floating around which are essentially bare objects whose attributes | I access,

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

2013-05-20 Thread Cameron Simpson
On 20May2013 13:23, Greg Ewing greg.ew...@canterbury.ac.nz wrote: | Cameron Simpson wrote: | It's an int _subclass_ so that it is no bigger than an int. | | If you use __slots__ to eliminate the overhead of an | instance dict, you'll get an object consisting of a | header plus one reference,

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

2013-05-19 Thread Peter Otten
Cameron Simpson wrote: TL;DR: I think I want to modify an int value in place. Yesterday I was thinking about various flag set objects I have floating around which are essentially bare objects whose attributes I access, for example: flags = object() flags.this = True flags.that =

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

2013-05-19 Thread Gregory Ewing
Cameron Simpson wrote: It's an int _subclass_ so that it is no bigger than an int. If you use __slots__ to eliminate the overhead of an instance dict, you'll get an object consisting of a header plus one reference, which is probably about the size of an int. But you'll also need an int to put

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

2013-05-18 Thread Cameron Simpson
TL;DR: I think I want to modify an int value in place. Yesterday I was thinking about various flag set objects I have floating around which are essentially bare objects whose attributes I access, for example: flags = object() flags.this = True flags.that = False and then elsewhere: if

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

2013-05-18 Thread Chris Angelico
On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson c...@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

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

2013-05-18 Thread Cameron Simpson
On 19May2013 11:11, Chris Angelico ros...@gmail.com wrote: | On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson c...@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