Comment #3 on issue 1463 by ondrej.certik: Initial codegen implementation
http://code.google.com/p/sympy/issues/detail?id=1463

The code looks good, all tests pass, so the patches are +1 from me, it's a  
good
beginning. I'll wait some time if others want to review it too, before I  
push it in.

In the meantime, please review the attached patch.

Some ideas for improvement:

* the codegen() function should have some example doctests, so that one can  
quickly
get an idea how it works.

* maybe import codegen directly into the sympy namespace? currently one has  
to
remember to import "from sympy.utilities.codegen import codegen"

In [1]: from sympy.utilities.codegen import codegen

In [2]: codegen?
Type:           function
Base Class:     <type 'function'>
String Form:    <function codegen at 0x1e15320>
Namespace:      Interactive
File:           /home/ondrej/repos/sympy/sympy/utilities/codegen.py
Definition:     codegen(name_expr, language, prefix, project='project')
Docstring:
     Write source code for the given expressions in the given language.

     Mandatory Arguments:
       name_expr  --  A single (name, expression) tuple or a list of
                      (name, expression) tuples. Each tuple corresponds to a
                      routine
       language  --  A string that indicates the source code language. This
                     is case insensitive. For the moment, only 'C' is
                     supported.
       prefix  --  A prefix for the names of the files that contain the  
source
                   code. Proper (language dependent) suffixes will be
                   appended.

     Optional Arguments:
       project  --  A project name, used for making unique preprocessor
                    instructions.

At least add there the following basic example:

>>> from sympy.utilities.codegen import codegen
>>> codegen(("f", x+y*z), "C", "test")

The only problem with the above is that it generates files on the disk,  
which in
general is good, but sometimes one would just like to see the contents of  
it without
touching the disk (sometimes you might not be even allowed to touch the  
disk, e.g.
the google app engine, where you'd like to send the file to the user  
instead), so
there should be a kw argument, something like h_file=None, c_file=None, and  
if you
supply an open stream (file, or StringIO, or whatever), it will just write  
to it,
otherwise to the disk.


* a lot more tests should be written


Attachments:
        0001-Allow-SYMPY_TEST_CLEAN_TEMP-never.patch  1.3 KB

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to