Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(227)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 3863042: Implement PEP 3118 struct changes

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years ago by minge
Modified:
11 years, 4 months ago
Reviewers:
pv, dickinsm
Base URL:
http://svn.python.org/view/*checkout*/python/branches/py3k/
Visibility:
Public.
This patch implements the current work in a first step towards implementing the extended struct format string support called for in PEP 3118. Namely, the support for nested structures via 'T{}' is implemented.

Patch Set 1 #

Total comments: 8
Created: 15 years ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+842 lines, -243 lines) Patch
Doc/library/struct.rst View 4 chunks +58 lines, -2 lines 2 comments Download
Lib/test/test_struct.py View 2 chunks +185 lines, -0 lines 1 comment Download
Modules/_struct.c View 17 chunks +599 lines, -241 lines 5 comments Download
Total messages: 2
|
minge
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c File Modules/_struct.c (right): http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c#newcode1666 Modules/_struct.c:1666: PyObject *tup = PyTuple_New(0); Since we know the number ...
15 years ago (2011年01月07日 03:59:45 UTC) #1
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c
File Modules/_struct.c (right):
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c#newcode1666
Modules/_struct.c:1666: PyObject *tup = PyTuple_New(0);
Since we know the number of arguments that we are unpacking, we should use
'PyTuple_New(tree->s_len)' here followed by 'PyTuple_SetItem" calls in the loop.
 Then we can get rid off all the nasty 'PySequence_Concat' calls.
Sign in to reply to this message.
pv
Some comments attached. I wrote some additional things you may wish to put in: (a) ...
14 years, 10 months ago (2011年02月12日 19:31:43 UTC) #2
Some comments attached.
I wrote some additional things you may wish to put in:
(a) Support for the '^' byte order character:
https://bitbucket.org/pv/cpython-stuff/changeset/ab9653885bd5
(b) Support for the 'i:fieldname:' field names. They are just skipped, though,
but it's probably a good idea to try to support the PEP 3118 syntax as closely
as feasible...
https://bitbucket.org/pv/cpython-stuff/changeset/e04591f57ccb
http://codereview.appspot.com/3863042/diff/1/Doc/library/struct.rst
File Doc/library/struct.rst (right):
http://codereview.appspot.com/3863042/diff/1/Doc/library/struct.rst#newcode99
Doc/library/struct.rst:99: 
The "^" code is missing from the table below.
http://codereview.appspot.com/3863042/diff/1/Doc/library/struct.rst#newcode152
Doc/library/struct.rst:152: 
Also "^" does not add padding.
http://codereview.appspot.com/3863042/diff/1/Lib/test/test_struct.py
File Lib/test/test_struct.py (right):
http://codereview.appspot.com/3863042/diff/1/Lib/test/test_struct.py#newcode697
Lib/test/test_struct.py:697: 
The tests for alignment handling is not fully complete.
I wonder if the tests from Numpy's implementation could be ported here; although
also that takes some trouble...
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c
File Modules/_struct.c (right):
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c#newcode1301
Modules/_struct.c:1301: return isdigit(c);
This probably shouldn't check for isdigit (count => it's not primitive). The
count needs only be parsed by `parse_format_string_body`.
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c#newcode1307
Modules/_struct.c:1307: static char *byte_order_codes = "<>!=@";
What about the '^' byte order marker? It's introduced in pep-3118 as
native-endian no-alignment.
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c#newcode1449
Modules/_struct.c:1449: while (*state->fmt == 'T' || is_primitive(*state->fmt))
{
... || isdigit(*state->fmt)
http://codereview.appspot.com/3863042/diff/1/Modules/_struct.c#newcode1824
Modules/_struct.c:1824: n = tree->s_size;
Should too long an input string be an error?
Sign in to reply to this message.
|
Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /