Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4776 > unrolled thread

avro slow?

Started byMiki Tebeka <miki.tebeka@gmail.com>
First post2011-05-05 14:12 -0700
Last post2011-05-06 01:18 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  avro slow? Miki Tebeka <miki.tebeka@gmail.com> - 2011-05-05 14:12 -0700
    Re: avro slow? Stefan Behnel <stefan_ml@behnel.de> - 2011-05-06 01:18 +0200

#4776 — avro slow?

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2011-05-05 14:12 -0700
Subjectavro slow?
Message-ID<98cd6085-bb77-417b-80e4-68ca990001cf@glegroupsg2000goo.googlegroups.com>
Greetings,

I'm reading some data from avro file using the avro library. It takes about a minute to load 33K objects from the file. This seem very slow to me, specially with the Java version reading the same file in about 1sec.

Here is the code, am I doing something wrong?

    import avro.datafile
    import avro.io
    from time import time

    def load(filename):
        fo = open(filename, "rb")
        reader = avro.datafile.DataFileReader(fo, avro.io.DatumReader())
        for i, record in enumerate(reader):
            pass

        return i + 1

    def main(argv=None):
        import sys
        from argparse import ArgumentParser

        argv = argv or sys.argv

        parser = ArgumentParser(description="Read avro file")


        start = time()
        num_records = load("events.avro")
        end = time()

        print("{0} records in {1} seconds".format(num_records, end - start))

    if __name__ == "__main__":
        main()

[toc] | [next] | [standalone]


#4781

FromStefan Behnel <stefan_ml@behnel.de>
Date2011-05-06 01:18 +0200
Message-ID<mailman.1209.1304637497.9059.python-list@python.org>
In reply to#4776
Dan Stromberg, 06.05.2011 00:36:
> Python is often more about programmer efficiency than
> machine efficiency.  With cost per MIPS going down and the price of
> programmer time going up, it seems a good idea.

Especially when you also count the MIPS improvement during the time it 
takes to write the code.

Stefan

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web