Sorry for the full lines. They were wrapped here but were sent unfolded.
It seems I need to rewrap on Thunderbird.
--
~Jugurtha Hadjar,
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
On 02/04/2015 12:18 AM, Steven D'Aprano wrote:
Not necessarily. Consider:
class A(object):
spam = 23
def __init__(self):
self.eggs = 42
In this case, the spam attribute is on the class, not the instance,
and so it doesn't matter how many A instances you have, there is only
On 2/3/2015 1:12 PM, Jugurtha Hadjar wrote:
Hello,
I was writing something and thought: Since the class had some
'constants', and multiple instances would be created, I assume that each
instance would have its own data. So this would mean duplication of the
same constants? If so, I thought why
Summary questions:
1 - Why are foo's and bar's class sizes the same? (foo's just a nop)
i'm not sure on this one.
2 - Why are foo() and bar() the same size, even with bar()'s 4 integers?
neither foo() nor bar() return anything explicitly, so both return the
default none
This needs
On Tue, Feb 3, 2015 at 3:59 PM, Emile van Sebille em...@fenx.com wrote:
On 2/3/2015 1:12 PM, Jugurtha Hadjar wrote:
2 - Why are foo() and bar() the same size, even with bar()'s 4 integers?
neither foo() nor bar() return anything explicitly, so both return the
default none
This is not
Jugurtha Hadjar wrote:
Hello,
I was writing something and thought: Since the class had some
'constants', and multiple instances would be created, I assume that each
instance would have its own data. So this would mean duplication of the
same constants? If so, I thought why not put the
On 02/03/2015 04:12 PM, Jugurtha Hadjar wrote:
Hello,
Lots of other good comments, so I'll just remark on one point.
class bar(object):
...def __init__(self):
...self.w = 5
...self.x = 6
...self.y = 7
...self.z = 8
If these really are constants,
On 02/03/2015 11:28 PM, Zachary Ware wrote:
For the OP: while this will probably be a nice exercise for learning
more about Python's internals, please keep in mind that 9 times out of
10 you won't need to worry about memory usage in Python, especially
not before you've proven to yourself that
On 02/03/2015 10:57 PM, Danny Yoo wrote:
But what is the documented behavior of sys.getsizeof?
Reading...
https://docs.python.org/3/library/sys.html#sys.getsizeof
Ah !
I was reading this:
https://docs.python.org/2/library/sys.html#sys.getsizeof
The unlocking phrase:
Only
On Tue, Feb 03, 2015 at 10:12:09PM +0100, Jugurtha Hadjar wrote:
Hello,
I was writing something and thought: Since the class had some
'constants', and multiple instances would be created, I assume that each
instance would have its own data. So this would mean duplication of the
same
On 02/03/2015 11:40 PM, Peter Otten wrote:
CPython already does this for many common values, e. g. small integers and
variable names
a = 42
b = 42
a is b
True
a = 300
b = 300
a is b
False
The threshold seems to be 256 (last value where it evaluates to True):
a = 1
b = 1
same = True
class bar(object):
... def __init__(self):
... self.w = 5
... self.x = 6
... self.y = 7
... self.z = 8
sys.getsizeof(bar())
28
3 - Why's bar()'s size smaller than the sum of the sizes of 4 integers?
But what is the documented behavior
12 matches
Mail list logo