Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue15436] __sizeof__ is not documented

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jul 23, 2012, 12:57 PM

Post #1 of 14 (119 views)
Permalink
[issue15436] __sizeof__ is not documented

Changes by Serhiy Storchaka <storchaka [at] gmail>:


----------
title: __sizeof__ is not documeneted -> __sizeof__ is not documented

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 23, 2012, 4:10 PM

Post #2 of 14 (110 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Jesús Cea Avión <jcea [at] jcea> added the comment:

Could you possibly write a patch for 2.7, 3.2 and 3.3?

----------
nosy: +jcea

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 23, 2012, 10:45 PM

Post #3 of 14 (110 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> Could you possibly write a patch for 2.7, 3.2 and 3.3?

No, not for documentation.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 23, 2012, 11:11 PM

Post #4 of 14 (112 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Eric Snow <ericsnowcurrently [at] gmail> added the comment:

is __sizeof__ part of the language or just an implementation detail?

----------
nosy: +eric.snow

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 23, 2012, 11:58 PM

Post #5 of 14 (109 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

See issue2898.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 24, 2012, 8:57 AM

Post #6 of 14 (111 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Meador Inge <meadori [at] gmail> added the comment:

It is part of runtime services and is mentioned in the documentation for 'sys.getsizeof' [1]:

"""
getsizeof() calls the object’s __sizeof__ method and adds an additional garbage collector overhead if the object is managed by the garbage collector.
"""

[1] http://docs.python.org/library/sys.html?highlight=__sizeof__#sys.getsizeof.

----------
nosy: +meador.inge

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 24, 2012, 9:51 AM

Post #7 of 14 (111 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

> It is part of runtime services and is mentioned in the documentation for
> 'sys.getsizeof' [1]:

Yes, but it is not mentioned in the index.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 24, 2012, 9:52 PM

Post #8 of 14 (113 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Eric Snow <ericsnowcurrently [at] gmail> added the comment:

issue2898 smells like an implementation detail to me. Also, sys.getsizeof() isn't necessarily authoritative here, since the sys module is full of all sorts of implementation details.

I'm not saying __sizeof__ shouldn't be made an official part of the language, but we should be careful before we effectively etch something in stone for all Python implementations. It may be worth getting feedback from python-dev, particularly from the major Python implementers.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 25, 2012, 4:03 PM

Post #9 of 14 (101 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Raymond Hettinger <raymond.hettinger [at] gmail> added the comment:

This may be CPython specific.

Also, sys.getsizeof() hasn't proved to be very useful (I never see anyone use it or see it in production code). Worse, it doesn't even make sense in the case of shared-key dictionaries and whatnot. Accordingly, there is little reason to make this more public than it already is. I would be happy to see it written-off as an implementation detail.

----------
nosy: +rhettinger

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 25, 2012, 4:05 PM

Post #10 of 14 (101 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Antoine Pitrou <pitrou [at] free> added the comment:

sys.getsizeof() is not for production code, it's for experimenting and getting information at the command prompt. It's quite useful when you know its limitations.

I'd argue that implementing __sizeof__ for user types doesn't make much sense (except C extension types, which are CPython-specific).

----------
nosy: +pitrou

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 25, 2012, 10:59 PM

Post #11 of 14 (104 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Changes by Chris Rebert <pybugs [at] rebertia>:


----------
nosy: +cvrebert

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 9:18 AM

Post #12 of 14 (103 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Martin v. Löwis added the comment:

rhettinger: users frequently need sys.getsizeof. See, for example,

http://stackoverflow.com/questions/1331471/in-memory-size-of-python-stucture
http://stackoverflow.com/questions/449560/how-do-i-determine-the-size-of-an-object-in-python
http://stackoverflow.com/questions/2117255/python-deep-getsizeof-list-with-contents
http://stackoverflow.com/questions/11301295/measure-object-size-accurately-in-python-sys-getsizeof-not-functioning
[and so on]

In what cases, do you think, it generates meaningless results? I find the results for the shared-keys dictionary quite meaningful and natural.

sys.getsizeof is certainly CPython-specific. However, __sizeof__ is not just an implementation detail of sys.getsizeof, just as __len__ is not an implementation detail of len(). Authors of extension types are supposed to implement it if object.__sizeof__ is incorrect.

----------
nosy: +loewis

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 9:57 AM

Post #13 of 14 (99 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Serhiy Storchaka added the comment:

> sys.getsizeof is certainly CPython-specific. However, __sizeof__ is not
> just an implementation detail of sys.getsizeof, just as __len__ is not an
> implementation detail of len(). Authors of extension types are supposed to
> implement it if object.__sizeof__ is incorrect.

I think there is one difference between __len__ and __sizeof__. __sizeof__
should be overloaded only for C-implemented classes. IMHO, it is a part of C
API.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 29, 2012, 10:31 AM

Post #14 of 14 (100 views)
Permalink
[issue15436] __sizeof__ is not documented [In reply to]

Martin v. Löwis added the comment:

> I think there is one difference between __len__ and __sizeof__. __sizeof__
> should be overloaded only for C-implemented classes. IMHO, it is a part of C
> API.

That is a reasonable point. So documenting it along with the type slots
might be best.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue15436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.