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 2009年02月03日 18:53 by bgailer, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg81085 - (view) | Author: bob gailer (bgailer) | Date: 2009年02月03日 18:53 | |
struct.calcsize('cd') returns 16 instead of 9
struct.calcsize('dc') returns 9 as expected
|
|||
| msg81089 - (view) | Author: bob gailer (bgailer) | Date: 2009年02月03日 19:13 | |
Someone pointed out that one must consider alignment. I had overlooked that. It makes sense that a d is double-word aligned. Perhaps the documentation should mention alignment. |
|||
| msg81193 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2009年02月05日 10:33 | |
The docs have this sentence: """ By default, C numbers are represented in the machine's native format and byte order, and properly aligned by skipping pad bytes if necessary (according to the rules used by the C compiler). """ What would you suggest be added? |
|||
| msg81197 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2009年02月05日 10:46 | |
The default endiand and alignment is "native". Using <, >, = or !
endian, the alignement is standard.
Python 3.1a0 (py3k:69105M, Feb 3 2009, 15:04:35)
>>> struct.calcsize('cd')
12
>>> struct.calcsize('=cd')
9
>>> struct.calcsize('<cd')
9
|
|||
| msg84249 - (view) | Author: STINNER Victor (vstinner) * (Python committer) | Date: 2009年03月27日 01:38 | |
Sorry, but I don't see this issue as a bug because it's related to memory alignment as explained in the documentation. I choose to close this issue. If you think that the documentation should be improved, please suggest an updated doc. http://docs.python.org/library/struct.html#struct.calcsize |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:45 | admin | set | github: 49395 |
| 2009年03月27日 01:38:34 | vstinner | set | status: open -> closed resolution: not a bug messages: + msg84249 |
| 2009年02月05日 10:46:52 | vstinner | set | nosy:
+ vstinner messages: + msg81197 |
| 2009年02月05日 10:33:24 | georg.brandl | set | messages: + msg81193 |
| 2009年02月03日 19:44:22 | pitrou | set | assignee: georg.brandl components: + Documentation, - Extension Modules nosy: + georg.brandl |
| 2009年02月03日 19:13:22 | bgailer | set | messages: + msg81089 |
| 2009年02月03日 18:53:42 | bgailer | create | |