hi,everyone. a problem with shelve Module

Discussion in 'Python' started by softwindow, May 26, 2006.

  1. softwindow

    softwindow Guest

    according to the book instruduction , i use shelve Module to write
    record to file.

    i only write ten records like this:

    name sex age

    jim male 22
    tom male 23
    lucy female 21

    ..................................................others( about ten
    records)

    but i find the size of this file .oh my god , it is about 24k

    the file is too large ! is it normal ?

    i don't dare to think that if i has 1000 records , it will be a very
    large file!
    softwindow, May 26, 2006
    #1
    1. Advertising

  2. softwindow

    Guest


    >> i only write ten records like this:


    >> name sex age


    >> jim male 22
    >> tom male 23
    >> lucy female 21

    ...

    >> but i find the size of this file .oh my god , it is about 24k


    >> the file is too large ! is it normal ?


    Yes. It's the nature of packages like Berkeley DB, gdbm and dbm (the
    packages mediate access to the database file under the covers) that they
    trade space for time. The files they create are not simple text files.
    They are organized to permit quick access to records by key and to permit
    average time fast insertion.

    Skip
    , May 26, 2006
    #2
    1. Advertising

  3. softwindow

    Laszlo Nagy Guest

    i'rta:
    > >> i only write ten records like this:

    >
    > >> name sex age

    >
    > >> jim male 22
    > >> tom male 23
    > >> lucy female 21

    > ...
    >
    > >> but i find the size of this file .oh my god , it is about 24k

    >
    > >> the file is too large ! is it normal ?

    >
    > Yes. It's the nature of packages like Berkeley DB, gdbm and dbm (the
    > packages mediate access to the database file under the covers) that they
    > trade space for time.

    Sometimes you add records but the size of the database does not
    change... :)
    > The files they create are not simple text files.
    > They are organized to permit quick access to records by key and to permit
    > average time fast insertion.
    >
    > Skip
    >
    Laszlo Nagy, May 26, 2006
    #3
  4. softwindow

    softwindow Guest

    really

    in which case?
    softwindow, May 26, 2006
    #4
  5. softwindow

    Jim Segrave Guest

    In article <>,
    softwindow <> wrote:
    [some context restored]
    >> Sometimes you add records but the size of the database does not
    >> change... :)

    >really
    >
    >in which case?


    whenever the database is big enough to add them without it's having to
    grow :)




    --
    Jim Segrave ()
    Jim Segrave, May 26, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PiedmontBiz
    Replies:
    0
    Views:
    291
    PiedmontBiz
    Jun 13, 2004
  2. Michael P. Soulier

    oddness in shelve module

    Michael P. Soulier, Jun 22, 2005, in forum: Python
    Replies:
    2
    Views:
    340
    John Machin
    Jun 22, 2005
  3. Thomas Ploch
    Replies:
    0
    Views:
    232
    Thomas Ploch
    Jan 10, 2007
  4. Guillaume Bog

    Shelve or pickle module

    Guillaume Bog, May 18, 2008, in forum: Python
    Replies:
    0
    Views:
    242
    Guillaume Bog
    May 18, 2008
  5. Alex
    Replies:
    0
    Views:
    228
Loading...

Share This Page