[issue29903] struct.Struct Addition

2017-04-21 Thread STINNER Victor
STINNER Victor added the comment: I dislike this feature. I reject it: Serhiy, Raymond and me dislike it. I never needed this feature and a correct implementation can be very complex if you have to take care of endian, alignement, etc. It's trivial to implement you own add using the format

[issue29903] struct.Struct Addition

2017-03-25 Thread Martin Panter
Martin Panter added the comment: For the native alignment case (prefix code @), perhaps you can already use the “ctypes” module, which supports structures with more complicated embedded fields. For the the unaligned modes (prefixes =, <, > and !), I am a little sympathetic. In the past, I

[issue29903] struct.Struct Addition

2017-03-25 Thread Aviv Palivoda
Aviv Palivoda added the comment: I have two use cases for this feature: 1. struct a { int a; #ifdef VER2 unsigned int b; #endif } Now I may do: >>> ver1 = Struct("i") >>> ver2 = ver1 + Struct("I") 2. struct a { int a; union inner { int b; unsigned int c; }

[issue29903] struct.Struct Addition

2017-03-25 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Serhiy that this proposal is likely to cause more problems than it solves. -- nosy: +rhettinger ___ Python tracker

[issue29903] struct.Struct Addition

2017-03-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What is the purpose of this feature? Note that the layout of the structure consisting of two structures is not the same as the layout of the structure consisting of the same fields as separate structures. struct { struct { char a; short

[issue29903] struct.Struct Addition

2017-03-25 Thread Aviv Palivoda
Changes by Aviv Palivoda : -- pull_requests: +723 ___ Python tracker ___ ___

[issue29903] struct.Struct Addition

2017-03-25 Thread Aviv Palivoda
New submission from Aviv Palivoda: I would like to suggest that the struct.Struct class will support addition. For example you will be able to do: >>> s1 = Struct(">L") >>> s2 = Struct(">B") >>> s3 = s1 + s2 >>> s3.format b">LB" -- components: Extension Modules messages: 290486 nosy: