[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2020-01-15 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2020-01-01 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
versions: +Python 3.9 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2020-01-01 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
pull_requests:  -17214

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2020-01-01 Thread Vinay Sajip


Change by Vinay Sajip :


--
pull_requests: +17214
pull_request: https://github.com/python/cpython/pull/17773

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2019-08-08 Thread Philip Dye


Change by Philip Dye :


--
nosy: +Philip Dye

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
stage: needs patch -> patch review
versions: +Python 3.7 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-10-14 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy:  -skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-06-29 Thread Stefan Krah

Stefan Krah added the comment:

Andrew, thanks for signing the agreement!


[Sunny]
 Is this what you expect?

I find the initialization in os.stat_result somewhat strange. Also,
a certain use of unnamed fields that worked in 2.5 is now broken,
which we should sort out before proceeding any further:


Apply structseq_repr_issue.diff, then:

 from _testcapi import mk_structseq
 s = mk_structseq(unnamed_end)
 s[3]
3
 tuple(s)
(0, 1, 2, 3, 4)
 s
Traceback (most recent call last):
  File stdin, line 1, in module
SystemError: In structseq_repr(), member 3 name is NULL for type 
_testcapi.struct_unnamed_end


Perhaps we should just add the missing field names, like namedtuple
does with rename=True:

(a=1, b=2, c=3, _4=4, _5=5)


In any case, in 2.5 the entire tuple was printed as the repr,
regardless of unnamed fields.

--
title: Enhance Object/structseq.c to match namedtuple and tuple api - Enhance 
Object/structseq.c to match namedtuple and tuple api
Added file: http://bugs.python.org/file35802/structseq_repr_issue.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-06-11 Thread Andrew Barnert

Andrew Barnert added the comment:

Hi, Stephan. Sorry, for some reason Yahoo was sending updates from the tracker 
to spam again, so I missed this. I'd be glad to sign a contributor agreement if 
it's still relevant, but it looks like there's a later patch that does what 
mine did and more?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-06-11 Thread Andrew Barnert

Andrew Barnert added the comment:

Sorry, Stefan, not Stephan. Anyway, I've signed the agreement.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-05-30 Thread Sunny K

Sunny K added the comment:

Hi Stefan,

There is a comment at the top in structseq.c

/* Fields with this name have only a field index, not a field name.
   They are only allowed for indices  n_visible_fields. */
char *PyStructSequence_UnnamedField = unnamed field;

This is the definition of os.stat_result in posixmodule.c:

static PyStructSequence_Field stat_result_fields[] = {
{st_mode,protection bits},
{st_ino, inode},
{st_dev, device},
{st_nlink,   number of hard links},
{st_uid, user ID of owner},
{st_gid, group ID of owner},
{st_size,total size, in bytes},
/* The NULL is replaced with PyStructSequence_UnnamedField later. */
{NULL,   integer time of last access},
{NULL,   integer time of last modification},
{NULL,   integer time of last change},
{st_atime,   time of last access},
{st_mtime,   time of last modification},
{st_ctime,   time of last change},
{st_atime_ns,   time of last access in nanoseconds},
{st_mtime_ns,   time of last modification in nanoseconds},
{st_ctime_ns,   time of last change in nanoseconds},
  ...


By visible i mean the values present in the repr of the object and by-extension 
accessible by position.

I talked about my problems with os.stat_result in points 3 and 4 of msg202333 
i.e repr of os.stat_result takes the first three keys from the attribute-access 
only fields (the invisible part) and uses them for the last three values in the 
displayed structseq.

With my current patch, _fields for os.stat_result only has 7 values:

 x = os.stat('.')
 x._fields
('st_mode', 'st_ino', 'st_dev', 'st_nlink', 'st_uid', 'st_gid', 'st_size')


Is this what you expect?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-05-30 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
versions: +Python 3.5 -Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-05-28 Thread Stefan Krah

Stefan Krah added the comment:

Sunny, is there a definition of visible positional fields? Currently,
it seems to me that in os.stat_result we have the opposite problem, namely
visible non-positional fields:

For example, st_atime_ns is visible but not indexable:

os.stat_result(st_mode=33188, st_ino=524840, st_dev=64513, st_nlink=1, 
st_uid=0, st_gid=0, st_size=2113, st_atime=1401225421, st_mtime=1398786163, 
st_ctime=1398786163)
 x[9]
1398786163
 x.st_atime_ns
1401225421887116783
 x[10] 
Traceback (most recent call last):
  File stdin, line 1, in module
IndexError: tuple index out of range

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-05-26 Thread Sunny K

Sunny K added the comment:

Hi Stefan,

I've added a new patch which only adds _fields, combining parts from my earlier 
patch and Andrew's (his patch does not account for visible unnamed fields).

--
Added file: http://bugs.python.org/file35367/structseq_fields.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-05-24 Thread Stefan Krah

Stefan Krah added the comment:

Hi Andrew.  Did you by any chance sign the contributor agreement?

[It's perfectly okay if you don't want to, but then we cannot use
the patch from #20230.]

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-04-29 Thread Stefan Krah

Stefan Krah added the comment:

Okay, if no one else wants this, I'll go ahead with the _fields part.

Andrew, could you sign a contributor agreement?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-04-28 Thread Stefan Krah

Stefan Krah added the comment:

Is accessing _fields a common operation?  Personally I'd use a
PyGetSetDef and generate the tuple on access (perhaps cache the
result).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-04-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 Is accessing _fields a common operation?

Not common at all -- it is used for introspection.

That said, there is nearly zero savings from generating the tuple upon look-up. 
 I would say that using a PyGetSetDef is a false optimization.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-04-27 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-04-27 Thread Stefan Krah

Stefan Krah added the comment:

 1. _asdict() returns a normal dictionary. I don't know if this is what
is required.

Good question. I don't think we can import OrderedDict from collections
because of the impact on startup time (_collections_abc was created to
avoid the issue for MutableMapping).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-04-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 any chance of the easy (_fields) change being committed 
 and putting off the harder parts until later?

Yes, it is not an all-or-nothing exercise.


 1. _asdict() returns a normal dictionary. I don't know if this is what
is required.

A regular dict would work just fine for now (there is a patch to introduce an 
OrderedDict in C, but that transition could be done later.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-01-12 Thread Andrew Barnert

Andrew Barnert added the comment:

See issue20230, which includes a patch implementing just the first part of part 
2 (adding _fields, but not _asdict or _replace).

Since this one has been open for 5+ years, if it's not going to be done soon, 
any chance of the easy (_fields) change being committed and putting off the 
harder parts until later?

--
nosy: +abarnert

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2014-01-12 Thread Ethan Furman

Changes by Ethan Furman et...@stoneleaf.us:


--
nosy: +ethan.furman

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-11-07 Thread Sunny K

Sunny K added the comment:

New patch for 3.4 adds the following:

1. _fields
2. _replace()
3. _asdict()
4. eval(repr(s)) == s

Now the issues:

1. _asdict() returns a normal dictionary. I don't know if this is what
   is required.

2. Both _asdict() and _replace() assume that unnamed visible fields are
   at the end of the visible sequence.  A comment at the beginning says
   they are allowed for indices  n_visible_fields.
   
   Is there another way to map members to values? Because tp-members
   is (visible named fields + invisible named fields) whereas values
   array is (visible named fields + visible unnamed fields + invisible
   named fields)

3. The mismatch mentioned above is present in the current
   implementation of repr:

   In os.stat_result, the last three visible fields are unnamed
   (i.e integer a_time, m_time and c_time). However they are present 
   in the repr output with keys which are the first three keys from the
   invisible part(float a_time, m_time and c_time).
   Was this intentional?

   Also, the above logic causes duplicate keys when invisible fields 
   are included in the repr output as per issue11629.
  
   In my patch for that issue, i put invisible fields under the 'dict'
   keyword argument. This output format utilises code already present 
   in structseq_new and makes eval work as expected when invisible 
   fields are present in repr. Also, it sidesteps the question of
   duplicated keys because they are present inside a dict.

4. Raymond stated that _fields should contain only the visible 
   positional fields. So _fields of os.stat_result contains only 7
   fields because of the three unnamed fields. Is this the expected 
   implementation?

5. Is there a way to declare a member function in C that accepts only 
   keyword arguments(like _replace())? I could not find one.

This is my first real C patch. So some of the issues might just be a
lack of understanding. Apologies.

--
keywords: +patch
nosy: +sunfinite
Added file: http://bugs.python.org/file32525/structseq_1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-11-07 Thread Sunny K

Sunny K added the comment:

Oops, the correct issue for improving the repr is issue11698.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-09-25 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-09-24 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-09-22 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

See also #5907.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-07-11 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Unassigning until another patch arrives that moves this forward.

The basic idea is well established:  Get the structseq API to match the named 
tuple API as much as possible.

--
assignee: rhettinger - 
components: +Extension Modules -Interpreter Core
priority: normal - low
stage:  - needs patch
versions: +Python 3.4 -Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2013-06-25 Thread Eric Snow

Eric Snow added the comment:

Would we also want to implement _make().

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2012-06-24 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


--
nosy: +eric.snow

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-07-13 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-04-16 Thread Santoso Wijaya

Changes by Santoso Wijaya santoso.wij...@gmail.com:


--
versions: +Python 3.3 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-04-08 Thread Santoso Wijaya

Changes by Santoso Wijaya santoso.wij...@gmail.com:


--
nosy: +santa4nt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-04-08 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

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)

--
nosy: +amaury.forgeotdarc

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-04-08 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

Also see issue 11698

--
assignee: jackdied - rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-04-08 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

Hasn't this been fixed in the following changeset?

changeset:   43509:384f73a104e9
user:Benjamin Peterson benja...@python.org
date:Wed Jul 07 20:54:01 2010 +
summary: make struct sequences subclass tuple; kill lots of code

--
nosy: +belopolsky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2011-04-08 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

 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.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-08-24 Thread Geoffrey Bache

Changes by Geoffrey Bache gjb1...@users.sourceforge.net:


--
nosy: +gjb1002

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-08-09 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Would whatever remains of this be deferred by the PEP3003 moratorium?

--
nosy: +terry.reedy
versions:  -Python 2.7, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-08-09 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

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.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-08-09 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

This is definitely not covered by the language moratorium.  Guido has requested 
this change and it needs to go forward.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-07-07 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

structseq now does subclass tuple, so if there's any interest in adding 
namedtuple APIs, now it should be easier.

--
nosy: +benjamin.peterson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-06-02 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' g.rod...@gmail.com:


--
nosy: +giampaolo.rodola

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-04-29 Thread Eric Smith

Changes by Eric Smith e...@trueblade.com:


--
nosy: +eric.smith

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-04-29 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

See also issue 8413, which would be addressed by this change.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2010-04-29 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

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).

--
priority: low - normal

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-26 Thread Ori Avtalion

Changes by Ori Avtalion o...@avtalion.name:


--
nosy: +salty-horse

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-26 Thread Ori Avtalion

Ori Avtalion o...@avtalion.name added the comment:

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?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-13 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Raymond Hettinger wrote:
 Raymond Hettinger rhettin...@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 ?

--
nosy: +lemburg
title: Enhance Object/structseq.c to match namedtuple and tuple api - Enhance 
Object/structseq.c to match namedtuple and tuple api

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-13 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

ISTM that structseq should have been a tuple subclass anyway.  Isn't it
advertised as some sort of tuple with attribute access?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-07-12 Thread Raymond Hettinger

Raymond Hettinger rhettin...@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;
   }

--
versions: +Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-04-01 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Jack, do you have any interest in putting this one over the goal line?

--
assignee: rhettinger - jackdied
nosy: +jackdied

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-02-10 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

See also issue 2308

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2009-01-02 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
versions: +Python 2.7, Python 3.1 -Python 2.6, Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1820
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-02-23 Thread Georg Brandl

Georg Brandl added the comment:

Is there something else to be done for this to be closed?

--
nosy: +georg.brandl

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-02-23 Thread Raymond Hettinger

Raymond Hettinger added the comment:

All three items are still open.  The second one is the easiest.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-14 Thread Raymond Hettinger

Changes by Raymond Hettinger:


--
assignee:  - rhettinger

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

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

Added file: http://bugs.python.org/file9170/structseq.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

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.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-14 Thread Leif Walsh

Leif Walsh added the comment:

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.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-14 Thread Raymond Hettinger

Raymond Hettinger added the comment:

It worked fine on a fresh check-out.  Committed in revision 59967.

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-13 Thread Christian Heimes

New submission from Christian Heimes:

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!

--
components: Interpreter Core
keywords: easy
messages: 59888
nosy: rhettinger, tiran
priority: low
severity: normal
status: open
title: Enhance Object/structseq.c to match namedtuple and tuple api
type: rfe
versions: Python 2.6, Python 3.0

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2008-01-13 Thread Leif Walsh

Leif Walsh added the comment:

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.

--
nosy: +adlaiff6
Added file: http://bugs.python.org/file9159/structseq_subclasses_tuple.diff

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1820
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com