GithubHelp home page GithubHelp logo

Comments (1)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 4, 2024
If you were using github or git I'd submit a PR; but since you're using SVN 
I've attached an updated copy of the prettytable.py. This version does two 
things:

1. Enables my use case above by introducing a new function - print_table() - 
that prints the lines to a file (default sys.stdout) instead of building them 
into a list.
Instead of:

print(myprettytable)

You do:

myprettytable.print_table()

It also takes a file and end parameter like the print() does so callers can 
redirect as desired.

2. Reduces memory significantly by using a generator - my test went from 
11-12GB of RAM down to just under 7 GB of RAM usage.

The original get_string() was split into a few more functions to re-use the 
code between the get_string() and print_table().

While this version works, and does a great job for the really big tables; it 
could be further improved if the formatted data did not have to be saved.

prettytable_alternate.py is an attempt to use more generators to reduce memory. 
Indeed it did work - peak was down to just over 5GB, and normal was around 
4.7GB - but it also took a lot longer to output the data (it also had to format 
the data twice due to the row generator). However, in both cases data is being 
outputted earlier than the original implementation since it can be outputted 
before all the data is completely built up.

Perhaps you have other ideas on how to speed this all up and reduce memory 
consumption for the very large table variants.

Original comment by [email protected] on 15 Dec 2014 at 11:35

Attachments:

from prettytable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.