|
msg59888 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-01-14 04:20 |
Raymond Hettinger wrote:
Here's a couple more if you want to proceed down that path:
1. Have structseq subclass from PyTupleObject so that isinstance(s,
tuple) returns True. This makes the object usable whenever
tuples are needed.
2. Add _fields, _asdict, and _replace to match the API in
collections.namedtuple(). The _fields tuple should only include the
visible positional fields while _asdict() and _replace() should include
all of the fields whether visible or accessible only by
attribute access.
3. Change the constructor to accept keyword args so that eval(repr(s))
== s works.
NOTE:
I've marked the task as easy but it's not a task for a total newbie.
It's a feasible yet challenging task for somebody who likes to get into
CPython core programming. Basic C knowledge is required!
|
|
msg59891 - (view) |
Author: Leif Walsh (adlaiff6) |
Date: 2008-01-14 07:03 |
Here is a patch for #1. I ran make test, and nothing was broken that
seemed to be my fault, so I assume it's okay.
Yes, it's small, it's my first one here. I'll get to the other two
tomorrow.
|
|
msg59949 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2008-01-15 01:21 |
Thanks for the patch. I removed the whitespace changes and added some
tests to make sure structseq now works with the % formatting operator
and isinstance(t,tuple).
Am getting a sporadic segfault in test_zipimport when running "make
test", so holding-off on applying:
test_zipimport
~/py26/Lib/test/test_zipimport.py:91: ImportWarning: Not importing
directory '/home/rhettinger/py26/Modules/zlib': missing __init__.py
["__dummy__"])
make: *** [test] Segmentation fault
|
|
msg59955 - (view) |
Author: Leif Walsh (adlaiff6) |
Date: 2008-01-15 02:01 |
I just svn upped (it updated zipimport) and applied your patch, and
'./python Lib/test/regrtest.py test_zipimport.py' says it's okay, so I
would go ahead and commit it.
|
|
msg59956 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2008-01-15 02:05 |
Run, "make test" a few times to make sure it doesn't bomb.
The problem may be due to needing a deferred_type instead of assigning
&PyTupleObject directly. Will look it more later.
|
|
msg59957 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2008-01-15 03:03 |
It worked fine on a fresh check-out. Committed in revision 59967.
|
|
msg62830 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2008-02-23 22:49 |
Is there something else to be done for this to be closed?
|
|
msg62831 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2008-02-23 22:54 |
All three items are still open. The second one is the easiest.
|
|
msg81627 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2009-02-11 04:46 |
See also issue 2308
|
|
msg85097 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2009-04-01 21:16 |
Jack, do you have any interest in putting this one over the goal line?
|
|
msg90461 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2009-07-12 22:48 |
In Py3.x, this fails:
"%s.%s.%s-%s-%s" % sys.version_info
The reason is that PyUnicode_Format() expects a real tuple, not a tuple
lookalike. The fix is to either have structseq inherit from tuple or to
modify PyUnicode_Format() to handle structseq:
if (PyCheck_StructSeq(args)) {
newargs = PyTuple_FromSequence(args);
if (newargs == NULL)
return NULL;
result = PyUncode_Format(format, newargs);
Py_DECREF(newargs);
return result;
}
|
|
msg90472 - (view) |
Author: Marc-Andre Lemburg (lemburg) *  |
Date: 2009-07-13 08:56 |
Raymond Hettinger wrote:
> Raymond Hettinger <rhettinger@users.sourceforge.net> added the comment:
>
> In Py3.x, this fails:
> "%s.%s.%s-%s-%s" % sys.version_info
>
> The reason is that PyUnicode_Format() expects a real tuple, not a tuple
> lookalike. The fix is to either have structseq inherit from tuple or to
> modify PyUnicode_Format() to handle structseq:
>
> if (PyCheck_StructSeq(args)) {
> newargs = PyTuple_FromSequence(args);
> if (newargs == NULL)
> return NULL;
> result = PyUncode_Format(format, newargs);
> Py_DECREF(newargs);
> return result;
> }
-1
The special-casing of tuples vs. non-tuples for % is already
bad enough. Adding structseq as another special case doesn't
make that any better.
What's so hard about writing
"%s.%s.%s-%s-%s" % tuple(sys.version_info)
anyway ?
|
|
msg90506 - (view) |
Author: Georg Brandl (georg.brandl) *  |
Date: 2009-07-13 22:01 |
ISTM that structseq should have been a tuple subclass anyway. Isn't it
advertised as some sort of "tuple with attribute access"?
|
|
msg90953 - (view) |
Author: Ori Avtalion (salty-horse) |
Date: 2009-07-26 18:03 |
For those who missed it, the patch that was committed in r59967 was
quickly reverted in r59970 with the comment:
"Temporarily revert 59967 until GC can be added."
Raymond, can you please explain what was missing from the patch?
|
|
msg104559 - (view) |
Author: Eric V. Smith (eric.smith) *  |
Date: 2010-04-29 18:21 |
See also issue 8413, which would be addressed by this change.
|
|
msg104562 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2010-04-29 18:34 |
I agree that the priority is higher now that we have a demonstrable regression.
Getting structseq to subclass from tuple will take some effort (tuples have many methods that would need to be overriden).
|
|
msg109503 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2010-07-07 21:31 |
structseq now does subclass tuple, so if there's any interest in adding namedtuple APIs, now it should be easier.
|
|
msg113451 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2010-08-09 18:50 |
Would whatever remains of this be deferred by the PEP3003 moratorium?
|
|
msg113453 - (view) |
Author: Eric V. Smith (eric.smith) *  |
Date: 2010-08-09 18:55 |
I don't think it would be covered by the moratorium, since it's not a language change. The change to make structseq derive from tuple was not subject to the moratorium, for example.
|
|
msg113456 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2010-08-09 19:02 |
This is definitely not covered by the language moratorium. Guido has requested this change and it needs to go forward.
|
|
msg133351 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) *  |
Date: 2011-04-08 23:02 |
Issue5907 would benefit of this change.
Unfortunately, structseq constructors already have keyword arguments; they are equivalent to "def __new__(cls, sequence, dict=NULL)".
OTOH these keywords arguments are not documented anywhere.
I suggest to change the constructor to something equivalent to:
"def __new__(cls, sequence=NULL, dict=NULL, *, field1=NULL, field2=NULL)"
|
|
msg133355 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2011-04-08 23:23 |
Also see issue 11698
|
|
msg133364 - (view) |
Author: Alexander Belopolsky (belopolsky) *  |
Date: 2011-04-09 00:53 |
Hasn't this been fixed in the following changeset?
changeset: 43509:384f73a104e9
user: Benjamin Peterson <benjamin@python.org>
date: Wed Jul 07 20:54:01 2010 +0000
summary: make struct sequences subclass tuple; kill lots of code
|
|
msg133367 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2011-04-09 01:02 |
> Hasn't this been fixed in the following changeset?
It was a major step forward. Now there needs to be work on other namedtuple methods and whatnot.
|
|
| Date |
User |
Action |
Args |
| 2012-06-25 01:05:44 | eric.snow | set | nosy:
+ eric.snow
|
| 2011-07-13 15:42:21 | eric.araujo | set | nosy:
+ eric.araujo
|
| 2011-04-20 22:17:48 | rhettinger | unlink | issue7796 dependencies |
| 2011-04-16 20:00:37 | santa4nt | set | versions:
+ Python 3.3, - Python 3.2 |
| 2011-04-09 01:02:30 | rhettinger | set | messages:
+ msg133367 |
| 2011-04-09 00:53:03 | belopolsky | set | nosy:
+ belopolsky messages:
+ msg133364
|
| 2011-04-08 23:23:55 | rhettinger | set | assignee: jackdied -> rhettinger messages:
+ msg133355 |
| 2011-04-08 23:02:42 | amaury.forgeotdarc | link | issue5907 dependencies |
| 2011-04-08 23:02:13 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages:
+ msg133351
|
| 2011-04-08 19:51:33 | santa4nt | set | nosy:
+ santa4nt
|
| 2010-11-28 05:11:16 | eric.araujo | link | issue7796 dependencies |
| 2010-08-24 19:07:54 | gjb1002 | set | nosy:
+ gjb1002
|
| 2010-08-09 19:02:00 | rhettinger | set | messages:
+ msg113456 |
| 2010-08-09 18:55:12 | eric.smith | set | messages:
+ msg113453 |
| 2010-08-09 18:50:48 | terry.reedy | set | nosy:
+ terry.reedy
messages:
+ msg113451 versions:
- Python 3.1, Python 2.7 |
| 2010-07-07 21:31:36 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages:
+ msg109503
|
| 2010-06-02 22:50:09 | giampaolo.rodola | set | nosy:
+ giampaolo.rodola
|
| 2010-04-29 18:34:17 | rhettinger | set | priority: low -> normal
messages:
+ msg104562 |
| 2010-04-29 18:21:47 | eric.smith | set | messages:
+ msg104559 |
| 2010-04-29 17:27:09 | eric.smith | set | nosy:
+ eric.smith
|
| 2009-07-26 18:03:04 | salty-horse | set | messages:
+ msg90953 |
| 2009-07-26 10:32:20 | salty-horse | set | nosy:
+ salty-horse
|
| 2009-07-13 22:01:06 | georg.brandl | set | messages:
+ msg90506 |
| 2009-07-13 08:56:27 | lemburg | set | nosy:
+ lemburg title: Enhance Object/structseq.c to match namedtuple and tuple api -> Enhance Object/structseq.c to match namedtuple and tuple api messages:
+ msg90472
|
| 2009-07-12 22:48:16 | rhettinger | set | messages:
+ msg90461 versions:
+ Python 3.2 |
| 2009-04-01 21:16:27 | rhettinger | set | assignee: rhettinger -> jackdied
messages:
+ msg85097 nosy:
+ jackdied |
| 2009-02-11 04:46:19 | rhettinger | set | messages:
+ msg81627 |
| 2009-02-11 04:39:11 | ajaksu2 | link | issue2308 superseder |
| 2009-01-02 21:49:34 | rhettinger | set | versions:
+ Python 3.1, Python 2.7, - Python 2.6, Python 3.0 |
| 2008-02-23 22:54:01 | rhettinger | set | messages:
+ msg62831 |
| 2008-02-23 22:49:45 | georg.brandl | set | nosy:
+ georg.brandl messages:
+ msg62830 |
| 2008-01-15 03:03:57 | rhettinger | set | messages:
+ msg59957 |
| 2008-01-15 02:05:38 | rhettinger | set | messages:
+ msg59956 |
| 2008-01-15 02:01:05 | adlaiff6 | set | messages:
+ msg59955 |
| 2008-01-15 01:21:34 | rhettinger | set | files:
+ structseq.diff messages:
+ msg59949 |
| 2008-01-15 00:33:03 | rhettinger | set | assignee: rhettinger |
| 2008-01-14 07:03:20 | adlaiff6 | set | files:
+ structseq_subclasses_tuple.diff nosy:
+ adlaiff6 messages:
+ msg59891 |
| 2008-01-14 04:20:27 | christian.heimes | create | |