-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello All,

I just tried to alter the database cursor for postgres [1] alone to add a new 
method which returns the data as list of namedtuples instead of list of 
dictionary.

Tests were done on party.party with all fields being fetched for 100,000 
records. the size was separately calculated using pympler [2]

1. List of Dictionary
===============
Time to read:
real            0m3.222s
user    0m2.373s
sys             0m0.295s

Memory footprint: 66804704

2. List of namedtuples
=================
Time to read:
real            0m2.237s
user    0m1.491s
sys             0m0.224s

Memory footprint: 8412336 (wov just 13% of list of dict :)

IMHO it makes sense to implement named tuples for read and I am starting the 
work on it. Hope to complete it soon.

[1] trytond/backend/postgres/database.py
[2] http://code.google.com/p/pympler/

Thanks,

Sharoon Thomas

On 6 Aug 2010, at 18:04, Cédric Krier wrote:

> On 06/08/10 17:44 +0100, Sharoon Thomas wrote:
>> Hi all,
>> 
>> I vote for the idea and I think it would be better to return a list of named
>> tuples (not sure if it can be used over xml rpc or other rpc).
>> 
>> Named tuples have the same memory footprint as normal tuples and gives class
>> attribute like functionality.
> 
> Already thought but I did not check in which version it was available. It
> seems it is 2.4 so it is ok.
> For xml-rpc and json-rpc, they should be converted to simple list and for
> netrpc we could add it as allowed objects.
> 
> -- 
> Cédric Krier
> 
> B2CK SPRL
> Rue de Rotterdam, 4
> 4000 Liège
> Belgium
> Tel: +32 472 54 46 59
> Email/Jabber: [email protected]
> Website: http://www.b2ck.com/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAkxi0wAACgkQaiEY2z2HLxqYPwCeNJjGVofc45SgoGAa0wFQmTxI
SxEAni8/h8tFLhkUkNQ6D5wUeG4o8Uxd
=6KfR
-----END PGP SIGNATURE-----

-- 
[email protected] mailing list

Reply via email to