Raymond Hettinger <[EMAIL PROTECTED]> added the comment:

Thanks for submitting the patch and the idea.

I've previously looked at this approach and decided against it.  The 
struct module is highly optimized and typically called many times in a 
loop and a patch like this would hurt performance.  Also, it adds 
complexity to the module making it more difficult to learn an remember.

It is better to leave named tuples separate and allow users to combine 
them downstream -- see the SQLite example for instance -- the cast to 
named tuples could be applied directly, so there was no need for a 
change to the SQL module.  It is better design for us to leave the data 
retrieval (struct, csv, sql, etc) separate from the code for 
collections.namedtuple.

Instead of this patch, I propose to add a simple example to the struct 
module documentation showing how to cast to a named tuple.  Also, 
FWIW,  the preferred way to cast tuples to named  tuples is to use the 
_make() method instead of using the constructor with the star 
operator.  nt._make(t) instead of nt(*t).

__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2909>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to