This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年07月23日 19:54 by serhiy.storchaka, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (15) | |||
|---|---|---|---|
| msg166245 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年07月23日 19:54 | |
__sizeof__ is not mentioned on page Doc/reference/datamodel.rst together with other special methods. There is no __sizeof__ in index. |
|||
| msg166253 - (view) | Author: Jesús Cea Avión (jcea) * (Python committer) | Date: 2012年07月23日 23:10 | |
Could you possibly write a patch for 2.7, 3.2 and 3.3? |
|||
| msg166263 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年07月24日 05:45 | |
> Could you possibly write a patch for 2.7, 3.2 and 3.3? No, not for documentation. |
|||
| msg166265 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2012年07月24日 06:11 | |
is __sizeof__ part of the language or just an implementation detail? |
|||
| msg166266 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年07月24日 06:58 | |
See issue2898. |
|||
| msg166304 - (view) | Author: Meador Inge (meador.inge) * (Python committer) | Date: 2012年07月24日 15:57 | |
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. |
|||
| msg166309 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年07月24日 16:51 | |
> 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. |
|||
| msg166353 - (view) | Author: Eric Snow (eric.snow) * (Python committer) | Date: 2012年07月25日 04:52 | |
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. |
|||
| msg166438 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2012年07月25日 23:03 | |
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. |
|||
| msg166439 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2012年07月25日 23:05 | |
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). |
|||
| msg166782 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年07月29日 16:18 | |
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. |
|||
| msg166789 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2012年07月29日 16:57 | |
> 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. |
|||
| msg166796 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年07月29日 17:31 | |
> 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. |
|||
| msg352974 - (view) | Author: Ido Michael (Ido Michael) * | Date: 2019年09月22日 12:11 | |
I can add those changes if someone didn't take it already? Ido |
|||
| msg364828 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2020年03月22日 22:33 | |
> I can add those changes if someone didn't take it already? I think we've decided that this is an implementation specific detail. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:33 | admin | set | github: 59641 |
| 2020年03月22日 22:33:40 | rhettinger | set | status: open -> closed resolution: not a bug messages: + msg364828 stage: needs patch -> resolved |
| 2020年03月22日 21:47:14 | Ido Michael | set | nosy:
- Ido Michael |
| 2019年09月22日 12:11:48 | Ido Michael | set | nosy:
+ Ido Michael messages: + msg352974 |
| 2019年08月09日 03:16:37 | Philip Dye | set | nosy:
+ Philip Dye |
| 2015年03月11日 12:02:40 | serhiy.storchaka | link | issue23639 dependencies |
| 2013年01月17日 00:38:27 | asvetlov | set | nosy:
+ asvetlov |
| 2013年01月15日 18:27:39 | serhiy.storchaka | set | keywords: + easy |
| 2012年10月30日 04:54:19 | mjdorma | set | nosy:
+ mjdorma |
| 2012年10月30日 04:53:17 | sptonkin | set | nosy:
+ sptonkin |
| 2012年10月24日 09:43:35 | serhiy.storchaka | set | stage: needs patch type: enhancement versions: + Python 3.4 |
| 2012年08月29日 12:04:37 | aliles | set | nosy:
+ aliles |
| 2012年07月29日 17:31:57 | loewis | set | messages: + msg166796 |
| 2012年07月29日 16:57:21 | serhiy.storchaka | set | messages: + msg166789 |
| 2012年07月29日 16:18:04 | loewis | set | nosy:
+ loewis messages: + msg166782 |
| 2012年07月26日 05:59:26 | cvrebert | set | nosy:
+ cvrebert |
| 2012年07月25日 23:05:31 | pitrou | set | nosy:
+ pitrou messages: + msg166439 |
| 2012年07月25日 23:03:08 | rhettinger | set | nosy:
+ rhettinger messages: + msg166438 |
| 2012年07月25日 04:52:20 | eric.snow | set | messages: + msg166353 |
| 2012年07月24日 16:51:44 | serhiy.storchaka | set | messages: + msg166309 |
| 2012年07月24日 15:57:08 | meador.inge | set | nosy:
+ meador.inge messages: + msg166304 |
| 2012年07月24日 06:58:46 | serhiy.storchaka | set | messages: + msg166266 |
| 2012年07月24日 06:11:44 | eric.snow | set | nosy:
+ eric.snow messages: + msg166265 |
| 2012年07月24日 05:45:14 | serhiy.storchaka | set | messages: + msg166263 |
| 2012年07月23日 23:10:00 | jcea | set | nosy:
+ jcea messages: + msg166253 |
| 2012年07月23日 19:57:46 | serhiy.storchaka | set | title: __sizeof__ is not documeneted -> __sizeof__ is not documented |
| 2012年07月23日 19:54:41 | serhiy.storchaka | create | |