-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys.getsizeof wrong for Py3k bool objects #47940
Comments
sys.getsizeof returns wrong results for bool objects in Python 3000. |
I'm not sure this is a bug. sys.getsizeof doesn't take padding in the |
As I understood the long object allocation it is implemented as Looking at bool objects in Py3k, arn't they fixed-sized memory-wise,
|
What's the actual difference that this change makes? At most 8 What's more, the small_ints aren't dynamically allocated, either, |
It would provide more accurate results, even in the light of being not
So how should this bug report be handled? Provide a patch to handle |
Fixing it for small_ints would be fine with me - there is specialized |
Attached is a patch which takes the preallocation of small_ints into |
I don't think there's anything worth fixing here. It's true that getsizeof is sometimes going to return results that are too small, because there are a good few places in the longobject internals where it's not predictable in advance exactly how much space is needed, so memory is overallocated. The case of the small int 0 is one example of this, but it's far from the only one. For example, if you multiply a 2-limb long by another 2-limb long the code will always allocate 4 limbs for the result, even though it'll often turn out that the result fits in 3 limbs. Should sys.getsizeof return base_size + 4 * sizeof_limb in that case, instead of base_size + 3 * sizeof_limb? That would be difficult to achieve, since long objects don't currently know how much space was actually allocated to hold them. |
Closing this as "won't fix", then. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: