Re: TIP#308 Published: Tcl Database Connectivity (TDBC)



Dnia 16-11-2007 o 17:00:52 Donal K. Fellows
<donal.k.fellows@xxxxxxxxxxxxxxxx> napisał(a):
(5) The primitive function to retrieve a row needs to retrieve it as
a list, IM(NS)HO. This is the natural structure to represent ordered
data as retrieved from a DBMS, and avoids a bunch of overhead
involved in creating and then parsing out a dict.
No. That *really* screws with Tcl's value system.

I have to say I disagree here. A lot.

First of all, I think SQLite's syntax (flat list) really rocks:

foreach {id name value} [$db eval {SELECT id,name,value FROM table}] {
...
}

Also, a list of lists is a really useful construction. For example you can
pass that directly to tablelist widget, so all you do is call delete 0 end
and do an insertlist $result on it.

Also, I'm not sure if that changed in 8.5, but [lsort] doesn't talk to
dicts nicely - so sorting a list of lists would work much better than
getting dictionaries.

While I know dicts would be the most elegant way, I don't think they're
the fastest (in terms of performance) and most powerful ones.

I think that query results should be returned as:
- flat list
- list of lists
- list of dicts

--
Wojciech Kocjan
.



Relevant Pages

  • Re: TIP#308 Published: Tcl Database Connectivity (TDBC)
    ... The representation of result set rows as dictionaries ... I have serious doubts about all aspects of dicts. ... form (list of lists), and tom.rmadilo raised a concern about handling ...
    (comp.lang.tcl)
  • Re: TIP#308: Last serial column value generated
    ... '-autocommit' is a redundant option. ... Stored procedures ... both dicts and lists are needed for result sets. ...
    (comp.lang.tcl)
  • Re: Making groups
    ... preserve order of the items in the list, ... I know how to do ordered dicts (or rather their useful cousins: ... consumption in order to store a richer per-entry data structure. ... lists. ...
    (comp.lang.tcl)
  • Re: New docs for set elements/dictionary keys
    ... >> used as a dictionary key/set element. ... Lists, sets and dicts are not hashable, and can not be ...
    (comp.lang.python)
  • Re: The fastest search
    ... dicts are much faster than lists. ... Don't even think about optimising your code until ... tests with lists of ten items if actual working data will have ten ...
    (comp.lang.python)