FAQ

On Oct 31, 2013, at 5:31 AM, "E.D.G." wrote:


Posted by E.D.G. on October 31, 2013

The following are several relatively basic questions regarding Python's capabilities. I am not presently using it myself. At the moment a number of people including myself are comparing it with other programs such as XBasic for possible use.

1. How fast can Python do math calculations compared with other languages such as Fortran and fast versions of Basic. I would have to believe that it is much faster than Perl for doing math calculations.

[byte]

4. How well does Python work for interactive programming. For example, if a Python program is running on a PC and is drawing a chart, can that chart be modified by simply pressing a key while the Python program is running. I have Perl and Gnuplot program combinations that can do that. Their interactive speed is not that great. But it is adequate for my own uses.

I thought about responding to this yesterday, decided others could do so better than I, but then decided to point out a bit of demo code that was one of the first really startling pieces of Python that I stumbled into.


If you look here: http://wiki.wxpython.org/MatplotlibFourierDemo


You will find a fairly short, well documented demo code that interactively computes a Fast Fourier transform from the frequency domain to the time domain. As you move the two sliders below the graphs, the input aptitude and location of the frequency peaks are changed and the resulting wavelet is plotted, all in real time.


Computing a Fourier transform is numerically pretty intensive, doing so in real time with no perceptible delay (at least on a reasonably modern system) should convince any skeptic of Python's ability to do BOTH number crunching AND interactive display.


Granted, this performance is based on pulling in libraries. It imports numpy, mathplotlib, and wx to handle the fast array calculations, the plotting, and the GUI respectively, but those are exactly the sorts of "batteries included" libraries that give Python so much power and flexibility.


-Bill

Search Discussions

  • Ethan Furman at Nov 1, 2013 at 6:08 pm

    On 11/01/2013 08:42 AM, William Ray Wing wrote:
    Granted, this performance is based on pulling in libraries. It imports numpy, mathplotlib, and wx to handle the fast array calculations, the plotting, and the GUI respectively, but those are exactly the sorts of "batteries included" libraries that give Python so much power and flexibility.

    Not to take away from your points about Python, combined with the appropriate libraries, being fast enough, but the
    "batteries included" refers to what comes in the stdlib -- those three libraries are not in the stdlib, so they're more
    along the lines of "power generators easily acquired". :)


    --
    ~Ethan~
  • William Ray Wing at Nov 1, 2013 at 7:17 pm

    On Nov 1, 2013, at 2:08 PM, Ethan Furman wrote:

    On 11/01/2013 08:42 AM, William Ray Wing wrote:

    Granted, this performance is based on pulling in libraries. It imports numpy, mathplotlib, and wx to handle the fast array calculations, the plotting, and the GUI respectively, but those are exactly the sorts of "batteries included" libraries that give Python so much power and flexibility.
    Not to take away from your points about Python, combined with the appropriate libraries, being fast enough, but the "batteries included" refers to what comes in the stdlib -- those three libraries are not in the stdlib, so they're more along the lines of "power generators easily acquired". :)

    --
    ~Ethan~
    --
    https://mail.python.org/mailman/listinfo/python-list

    Strictly speaking, you are absolutely correct. But, those three libraries are SO widely available (for so many platforms), I took the liberty of being inclusive.


    Thanks,
    Bill
  • E.D.G. at Nov 3, 2013 at 5:45 am
    "rusi" <rustompmody@gmail.com> wrote in message
    news:1e63687b-4269-42d9-8700-e3a8dcc5773f at googlegroups.com...

    Not sure what will? you may look at Julia: http://julialang.org/

            That program language speed comparison table looks quite interesting.
    And I asked some of the other people that I work with to take a look at the
    Web page. One or two of them might want to consider using it instead of
    XBasic assuming the calculation speeds and chart generation capabilities are
    at least roughly equal. If either of them decides to move in that direction
    I will probably try using it myself.
  • Rusi at Nov 3, 2013 at 6:54 am

    On Sunday, November 3, 2013 11:15:48 AM UTC+5:30, E.D.G. wrote:
    "rusi" wrote:
    Not sure what will? you may look at Julia: http://julialang.org/
    That program language speed comparison table looks quite interesting.
    And I asked some of the other people that I work with to take a look at the
    Web page. One or two of them might want to consider using it instead of
    XBasic assuming the calculation speeds and chart generation capabilities are
    at least roughly equal. If either of them decides to move in that direction
    I will probably try using it myself.

    And please post back your findings when you have some concrete data


    For the record I have exactly zero experience with Julia.
  • E.D.G. at Nov 3, 2013 at 6:02 am
    "E.D.G." <edgrsprj@ix.netcom.com> wrote in message
    news:UdGdnaDGa6n9vu_PnZ2dnUVZ_umdnZ2d at earthlink.com...


            Thanks for all of the comments. I have been away from my Internet
    connection for several days and could not respond to them when they were
    first posted here.


            The comments have all been considered. And I am discussing them with
    other researchers that I work with. Since Perl has a calculation speed limit
    that is probably not easy to get around, before too long another language
    will be selected for initially doing certain things such as performing
    calculations and plotting charts. And the existing Perl code might then be
    gradually translated into that new language.


            Gnuplot is presently being used to draw charts. And it works. But it
    has its own limitations such as with its interaction speed when it is used
    for working with Perl program generated data files.


            My main, complex programs won't be run at Web sites. They will
    instead continue to be available as downloadable exe programs. The CGI (or
    whatever) programming work would involve relatively simple programs. But
    they would need to be able to generate charts that would be displayed on Web
    pages. That sounds like it is probably fairly easy to do using Python. A
    Perl - Gnuplot combination is also supposed to be able to do that. But so
    far I have not seen any good explanations for how to actually get Gnuplot to
    run as a callable CGI program. So other programs such as Python are being
    considered.
  • Steven D'Aprano at Nov 3, 2013 at 7:43 am
    On Sun, 03 Nov 2013 01:02:24 -0500, E.D.G. wrote:


    [...]
    Since Perl has a calculation speed
    limit that is probably not easy to get around, before too long another
    language will be selected for initially doing certain things such as
    performing calculations and plotting charts. And the existing Perl code
    might then be gradually translated into that new language.

    The nice things about Python are that it makes a great glue language for
    putting together components written in low-level languages like C and
    Fortran, and that there is a rich ecosystem of products for speeding it
    up in various ways. So when you hit the speed limits of pure Python, you
    have lots of options. In no particular order:




    * try using another Python compiler: PyPy is probably the most
       mature of the stand-alone optimizing compilers, and you can
       expect to double the speed of "typical" Python code, but
       there are others;


    * use numpy and scipy for vectorized mathematical routines;


    * re-write critical code as C or Fortran libraries;


    * use Pyrex (possibly unmaintained now) or Cython to write
       C extensions in a Python-like language;


    * use Psyco or Numba (JIT specialising compilers for Python);


    * use Theano (optimizing computer algebra system compiler);


    * use ctypes to call C functions directly;


    * use other products like Boost, Weave, and more.




    See, for example:


    http://jakevdp.github.io/blog/2013/06/15/numba-vs-cython-take-2/


    http://technicaldiscovery.blogspot.com.au/2011/06/speeding-up-python-numpy-cython-and.html






    --
    Steven
  • E.D.G. at Nov 3, 2013 at 9:47 am
    "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> wrote in message
    news:5275fe91$0$29972$c3e8da3$5496439d at news.astraweb.com...


            It appears that Python can do what is needed. And if the people that
    I work with want to move in that direction I will probably post a note here
    stating, "This is exactly what we need to do. What would be the best Python
    download and compiler to do that?"


           It should be a simple matter to determine which compiler and libraries
    etc. should be used.
  • Mark Lawrence at Nov 3, 2013 at 10:05 am

    On 03/11/2013 09:47, E.D.G. wrote:
    "Steven D'Aprano" <steve+comp.lang.python@pearwood.info> wrote in
    message news:5275fe91$0$29972$c3e8da3$5496439d at news.astraweb.com...
    It appears that Python can do what is needed. And if the people
    that I work with want to move in that direction I will probably post a
    note here stating, "This is exactly what we need to do. What would be
    the best Python download and compiler to do that?"

    It should be a simple matter to determine which compiler and
    libraries etc. should be used.

    I've literally just stumbled across this, I've no idea whether it's of
    any use to you https://speakerdeck.com/ianozsvald/high-performance-python


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Rusi at Nov 3, 2013 at 6:28 pm

    On Sunday, November 3, 2013 1:13:13 PM UTC+5:30, Steven D'Aprano wrote:
    On Sun, 03 Nov 2013 01:02:24 -0500, E.D.G. wrote:
    [...]
    Since Perl has a calculation speed
    limit that is probably not easy to get around, before too long another
    language will be selected for initially doing certain things such as
    performing calculations and plotting charts. And the existing Perl code
    might then be gradually translated into that new language.
    The nice things about Python are that it makes a great glue language for
    putting together components written in low-level languages like C and
    Fortran, and that there is a rich ecosystem of products for speeding it
    up in various ways. So when you hit the speed limits of pure Python, you
    have lots of options. In no particular order:
    * try using another Python compiler: PyPy is probably the most
    mature of the stand-alone optimizing compilers, and you can
    expect to double the speed of "typical" Python code, but
    there are others;
    * use numpy and scipy for vectorized mathematical routines;
    * re-write critical code as C or Fortran libraries;
    * use Pyrex (possibly unmaintained now) or Cython to write
    C extensions in a Python-like language;
    * use Psyco or Numba (JIT specialising compilers for Python);
    * use Theano (optimizing computer algebra system compiler);
    * use ctypes to call C functions directly;
    * use other products like Boost, Weave, and more.

    Yes python is really state-of-art in this respect:
    Every language will have some area where it sucks.
    Allowing for a hatch where one could jump out is helpful.
    Python allows more such hatches than probably any other language (that I know)


    https://mail.python.org/pipermail/python-list/2012-August/628090.html
    is a (non exhaustive) list I had made some time.


    On the other hand if you know you are going to be escaping out often,
    you may want to consider whether the 'escapee' should be your base
    rather than python.


    Which means take something like the pairwise function and code it up in python and julia -- its hardly 10 lines of code. And see what comparative performance you get.
  • Mark Lawrence at Nov 3, 2013 at 6:58 pm

    On 03/11/2013 18:28, rusi wrote:
    Which means take something like the pairwise function and code it up in python and julia -- its hardly 10 lines of code. And see what comparative performance you get.

    Solely on the grounds that you've mentioned julia how about this
    http://blog.leahhanson.us/julia-calling-python-calling-julia.html


    --
    Python is the second best programming language in the world.
    But the best has yet to be invented. Christian Tismer


    Mark Lawrence
  • Rusi at Nov 4, 2013 at 4:07 am

    On Monday, November 4, 2013 12:28:24 AM UTC+5:30, Mark Lawrence wrote:
    On 03/11/2013 18:28, rusi wrote:
    Which means take something like the pairwise function and code it
    up in python and julia -- its hardly 10 lines of code. And see
    what comparative performance you get.
    Solely on the grounds that you've mentioned julia how about this
    http://blog.leahhanson.us/julia-calling-python-calling-julia.html

    Good stuff -- thanks
  • Jim Gibson at Nov 3, 2013 at 6:18 pm
    In article <okcdnxfaqqxze-jpnz2dnuvz_jgdnz2d@earthlink.com>, E.D.G.
    wrote:

    My main, complex programs won't be run at Web sites. They will
    instead continue to be available as downloadable exe programs. The CGI (or
    whatever) programming work would involve relatively simple programs. But
    they would need to be able to generate charts that would be displayed on Web
    pages. That sounds like it is probably fairly easy to do using Python. A
    Perl - Gnuplot combination is also supposed to be able to do that. But so
    far I have not seen any good explanations for how to actually get Gnuplot to
    run as a callable CGI program. So other programs such as Python are being
    considered.

    One way to generate plot within a CGI program is this:


    1. Write a file with gnuplot commands (e.g., 'gnuplot.cmd') that set
    the output device to a graphics file of some format (e.g., PNG),
    generate a plot, and quit gnuplot.


    2. Run gnuplot and point it to the file of commands (e.g., 'gnuplot
    gunplot.cmd') . How this is done depends upon the CGI program language
    (see below).


    3. Generate HTML that uses the generated graphics file as an embedded
    image (using the <img> tag).


    I have done this in the past, but not recently. This should work for
    Python (os.system("gnuplot gnuplot.cmd") or Perl (system("gnuplot
    gnuplot.cmd") with suitable commands to execute external programs.


    --
    Jim Gibson
  • Grant Edwards at Nov 3, 2013 at 11:16 pm

    On 2013-11-03, Jim Gibson wrote:
    In article <okcdnxfaqqxze-jpnz2dnuvz_jgdnz2d@earthlink.com>, E.D.G.
    wrote:
    My main, complex programs won't be run at Web sites. They will
    instead continue to be available as downloadable exe programs. The CGI (or
    whatever) programming work would involve relatively simple programs. But
    they would need to be able to generate charts that would be displayed on Web
    pages. That sounds like it is probably fairly easy to do using Python. A
    Perl - Gnuplot combination is also supposed to be able to do that. But so
    far I have not seen any good explanations for how to actually get Gnuplot to
    run as a callable CGI program. So other programs such as Python are being
    considered.
    One way to generate plot within a CGI program is this:

    1. Write a file with gnuplot commands (e.g., 'gnuplot.cmd') that set
    the output device to a graphics file of some format (e.g., PNG),
    generate a plot, and quit gnuplot.

    Or you can use the pygnuplot module which handles much of that for y0ou.


    http://pygnuplot.sourceforge.net/


    --
    Grant
  • E.D.G. at Nov 5, 2013 at 5:22 am
    "Jim Gibson" <jimsgibson@gmail.com> wrote in message
    news:031120131018099327%JimSGibson at gmail.com...

    One way to generate plot within a CGI program is this:

            To start off with, I am not a CGI expert. Also, I have several
    degrees in the physical sciences and many years of doing computer
    programming. But the programming work is done just to get various science
    projects to work.


            The question that I could not get an answer for was, ?How can you get
    Gnuplot to run on an Internet server computer??


            And I would eventually have to ask that same question for Python.


            My Internet Server looks like it has Perl, Perl5, and PHP available.
    And I have created a number of CGI Perl programs that run on the Web site.
    But as I said, I would not know how to get Gnuplot or Python to run at the
    site.


            Any recommendations for how to do that? Or should I just do a search
    for the necessary documentation?
  • 88888 Dihedral at Nov 7, 2013 at 2:05 pm

    On Tuesday, November 5, 2013 1:22:05 PM UTC+8, E.D.G. wrote:
    "Jim Gibson" <jimsgibson@gmail.com> wrote in message

    news:031120131018099327%JimSGibson at gmail.com...


    One way to generate plot within a CGI program is this:


    To start off with, I am not a CGI expert. Also, I have several

    degrees in the physical sciences and many years of doing computer

    programming. But the programming work is done just to get various science

    projects to work.



    The question that I could not get an answer for was, ?How can you get

    Gnuplot to run on an Internet server computer??



    And I would eventually have to ask that same question for Python.



    My Internet Server looks like it has Perl, Perl5, and PHP available.

    And I have created a number of CGI Perl programs that run on the Web site.

    But as I said, I would not know how to get Gnuplot or Python to run at the

    site.



    Any recommendations for how to do that? Or should I just do a search

    for the necessary documentation?

    Please try modpy.
  • E.D.G. at Nov 3, 2013 at 6:17 am
    "Mark Lawrence" <breamoreboy@yahoo.co.uk> wrote in message
    news:mailman.1873.1383227352.18130.python-list at python.org...


    Python "SendKey" looks like it probably works about the same as the Perl
    version. It prints or sends control information to the active window.
  • E.D.G. at Nov 12, 2013 at 10:21 am
    "E.D.G." <edgrsprj@ix.netcom.com> wrote in message
    news:yo-dnWFmi7_7d-jPnZ2dnUVZ_hqdnZ2d at earthlink.com...


    Posted by E.D.G. on November 12, 2013


            The following is part of a note that I just posted to the Perl
    Newsgroup. But it is actually intended for all computer programmers who are
    circulating free download software.


            One of the people that I work with and I are using an important
    computer program that is quite unique. It was created a long time ago by a
    highly regarded scientist who passed away a while back. And he made three
    copies of the program available for people as free downloads. The first is
    an exe version of the program that will run on any Windows machine. The
    second is the code for the program written using what is now an ancient
    version of Fortran. And the third is for the same program using an ancient
    version of Basic.


            The professional programmer and I attempted to produce versions of
    the program using a modern language. I managed the project and the
    programmer did the actual work. And unfortunately, in spite of his many
    years of experience he could not understand the Fortran and Basic versions
    to the point where he could translate them. I recommended that he post some
    notes to the Fortran Newsgroup and ask if anyone visiting that Newsgroup had
    an instruction manual for that ancient version of Fortran that would explain
    what the program code meant. But for some reason he chose not to do that.
    And it would have taken me a considerable amount of time to attempt the
    translation myself.


            So, the end result is that when the program needs to generate data,
    the exe version is used "as is." Or it is called from a Perl program and
    given the input information it needs so that it can generate data.


            The point is, when people want to make some computer program
    available for use by others around the world they might want to circulate a
    version of their program that has such a simple format that anyone can
    understand it. And for actual use they can generate parallel versions that
    have more efficient code that people who are working with that language can
    understand.
  • Chris Angelico at Nov 12, 2013 at 11:05 pm

    On Tue, Nov 12, 2013 at 9:21 PM, E.D.G. wrote:
    The point is, when people want to make some computer program available
    for use by others around the world they might want to circulate a version of
    their program that has such a simple format that anyone can understand it.
    And for actual use they can generate parallel versions that have more
    efficient code that people who are working with that language can
    understand.

    Sounds to me like something out of cryptography. You have a "reference
    implementation" that's slow, readable, and straight-forward, and then
    you have "optimized implementations" that are actually fast enough to
    use - but if any time you want to know if you're producing the right
    output, you just compare against the reference implementation.


    ChrisA
  • E.D.G. at Nov 3, 2013 at 6:28 am
    "William Ray Wing" <wrw@mac.com> wrote in message
    news:mailman.1934.1383320554.18130.python-list at python.org...


            A suggestion that I would like to add is that when people make "Demo"
    programs like that available they might want to create exe versions that
    people can download and try without installing the original programming
    language. However, there might have been an exe version at that Web site
    and I just didn't see it.


            I myself use expendable backup computers (Windows XP) for testing new
    exe programs so that problems are not created for my primary computer. If
    something goes wrong on one of the backup systems it is simply told to go
    back to an earlier restore point.
  • Sigtool at Nov 10, 2013 at 2:40 pm
    On Q4, you could try Waterloo Graphics <http://waterloo.sourceforge.net>. Its LGPLv3 and, although Java-based, runs in Python via Py4J. It has built-in mouse interactivity/GUI editors etc that will all be active when used from Python.


    It is Java Swing-based, so e.g. data points can be drawn as standard clickable Swing components (see http://waterloo.sourceforge.net/R/scatter.html for an example using R [N.B. not interactive on the web site which just shows a bit-map]).


    For Python examples see http://waterloo.sourceforge.net/python/grid.html













    On Thursday, October 31, 2013 9:31:11 AM UTC, E.D.G. wrote:
    Posted by E.D.G. on October 31, 2013



    The following are several relatively basic questions regarding Python's

    capabilities. I am not presently using it myself. At the moment a number

    of people including myself are comparing it with other programs such as

    XBasic for possible use.



    1. How fast can Python do math calculations compared with other languages

    such as Fortran and fast versions of Basic. I would have to believe that it

    is much faster than Perl for doing math calculations.



    2. Can Python be used to create CGI programs? These are the ones that run

    on Internet server computers and process data submitted through Web site

    data entry screens etc. I know that Perl CGI programs will do that.



    3. If Python can be used for CGI programming, can it draw charts such as

    .png files that will then display on Web pages at a Web site?



    4. How well does Python work for interactive programming. For example, if

    a Python program is running on a PC and is drawing a chart, can that chart

    be modified by simply pressing a key while the Python program is running. I

    have Perl and Gnuplot program combinations that can do that. Their

    interactive speed is not that great. But it is adequate for my own uses.



    5. Can a running Python program send information to the Windows operating

    system as if it were typed in from the keyboard? Perl can do that and I

    would imagine that Python probably has that same capability.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 1, '13 at 3:42p
activeNov 12, '13 at 11:05p
posts21
users11
websitepython.org

People

Translate

site design / logo © 2022 Grokbase