[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Meador Inge

Meador Inge added the comment:

Thanks for the patches!  (I fixed a minor nit on the 2.7 patch where 
'array_sizeof' was defined inside #ifdef Py_USING_UNICODE).

--
resolution:  -> fixed
stage: commit review -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 91382d4e2dfb by Meador Inge in branch '2.7':
Issue #15424: Add a __sizeof__ implementation for array objects.
http://hg.python.org/cpython/rev/91382d4e2dfb

New changeset 45ef9bc8739f by Meador Inge in branch '3.2':
Issue #15424: Add a __sizeof__ implementation for array objects.
http://hg.python.org/cpython/rev/45ef9bc8739f

New changeset 7d82a60850fd by Meador Inge in branch 'default':
Issue #15424: Add a __sizeof__ implementation for array objects.
http://hg.python.org/cpython/rev/7d82a60850fd

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Patches look good to me.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Changes by Ludwig Hähne :


Removed file: http://bugs.python.org/file26479/array_sizeof.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Changes by Ludwig Hähne :


Removed file: http://bugs.python.org/file26510/array_sizeof_v3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Ludwig Hähne added the comment:

Meador, Serhiy, I've add patches for Python 2.7 and Python 3.2 following Serhiy 
suggestions.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Changes by Ludwig Hähne :


Removed file: http://bugs.python.org/file26480/array_sizeof_v2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Changes by Ludwig Hähne :


Removed file: http://bugs.python.org/file26713/array_sizeof_v4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Changes by Ludwig Hähne :


Added file: http://bugs.python.org/file26757/array_sizeof_3.2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-10 Thread Ludwig Hähne

Changes by Ludwig Hähne :


Added file: http://bugs.python.org/file26756/array_sizeof_2.7.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-07 Thread Georg Brandl

Georg Brandl added the comment:

LGTM.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-07 Thread Meador Inge

Meador Inge added the comment:

Georg, yet another __sizeof__ fix.  OK for 3.3?

--
nosy: +georg.brandl
stage:  -> commit review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Patch looks good to me, however tests for 3.2 and 2.7 should be modified 
(change "n" struct format specifier to "P", remove last "i" and use 
test_support instead test.support (or import test_support as support) in 2.7).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-07 Thread Ludwig Hähne

Ludwig Hähne added the comment:

Meador, thanks for reviewing. The updated patch is now attached to the bug.

--
Added file: http://bugs.python.org/file26718/array_sizeof_v5.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-06 Thread Meador Inge

Meador Inge added the comment:

I left some commits in Rietveld.  Otherwise, looks OK.

--
assignee:  -> meador.inge

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-06 Thread Ludwig Hähne

Ludwig Hähne added the comment:

Serhiy, the tests now explicitly check the base size of the array.

I'm not sure if I got the base size compution right (only checked on 32bit 
Linux). Could you check that the struct definition in the test makes sense and 
matches the C arrayobject definition? Thanks, Ludwig

--
Added file: http://bugs.python.org/file26713/array_sizeof_v4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-08-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ludwig, you can use some helpers from test.support (see issue15467) for 
__sizeof__ testing.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-25 Thread Ludwig Hähne

Ludwig Hähne  added the comment:

Revised the patch based on the discussion in issue #15402 
(http://bugs.python.org/msg166372). It doesn't typecast the function anymore 
and instead casts to the array type inside the function.

--
Added file: http://bugs.python.org/file26510/array_sizeof_v3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-23 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +meador.inge
versions: +Python 3.2 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-23 Thread Jesús Cea Avión

Jesús Cea Avión  added the comment:

With the precedent of issue #15402, I think that 2.7 and 3.2 should be fine.

--
nosy: +jcea

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-22 Thread Ludwig Hähne

Ludwig Hähne  added the comment:

Yes, it would be great if the change could be applied to 3.2 (and 2.7) but I 
guess not many people will be affected by the problem.

BTW, I just submitted the contributor form.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-22 Thread Ludwig Hähne

Ludwig Hähne  added the comment:

Uses self->allocated instead of Py_SIZE as Martin suggested.

--
Added file: http://bugs.python.org/file26480/array_sizeof_v2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-22 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

I think it should be applied to 3.2 too.

--
nosy: +storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-22 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

Can you please submit a contributor form?

--
nosy: +loewis

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15424] __sizeof__ of array should include size of items

2012-07-22 Thread Ludwig Hähne

New submission from Ludwig Hähne :

If sys.getsizeof is called on an array, the result doesn't include the size of 
the items: 

>>> from array import array
>>> a = array("i", [0] * 10)
>>> a.__sizeof__()
40

While this makes sense for a list, an array doesn't have separate referents 
that could be sized:

>>> import gc
>>> gc.get_referents(a)
[]

The attached patch adds an implementation of the __sizeof__ method for arrays 
that includes the size of the buffer for the elements.

It would be great if the patch would be considered for one of the upcoming 
versions of Python.

Thanks, Ludwig

--
components: Library (Lib)
files: array_sizeof.patch
keywords: patch
messages: 166147
nosy: Pankrat
priority: normal
severity: normal
status: open
title: __sizeof__ of array should include size of items
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file26479/array_sizeof.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com