Ticket #11712: trac_11712.patch

File trac_11712.patch, 3.2 KB (added by malb, 10 years ago)
  • sage/misc/cython_c.pyx

    # HG changeset patch
    # User Martin Albrecht <martinralbrecht@googlemail.com>
    # Date 1313996997 -3600
    # Node ID 6e35196583ab460f3905a24708964d93d62f94c7
    # Parent  e2d83cf337d8131bf19620c4a797d2f36cc0611c
    #11712: add documentation about pragmas to cython() function
    
    diff -r e2d83cf337d8 -r 6e35196583ab sage/misc/cython_c.pyx
    a b  
    55          verbose=False, compile_message=False,
    66          make_c_file_nice=False, use_cache=False):
    77    """
    8     Given a block of Cython (Sage's variant of Pyrex) code (as a text
    9     string), this function compiles it using your C compiler, and
    10     includes it into the global scope of the module that called this
    11     function.
     8    Given a block of Cython code (as a text string), this function
     9    compiles it using a C compiler, and includes it into the global
     10    scope of the module that called this function.
    1211
    13     WARNING: Only use this from Python code, not from extension code,
    14     since from extension code you would change the global scope (i.e.,
    15     of the Sage interpreter). And it would be stupid, since you're
    16     already writing Cython!
     12    The following pragmas are available:
    1713
    18     Also, never use this in the standard Sage library.  Any code that
    19     uses this can only run on a system that has a C compiler
    20     installed, and we want to avoid making that assumption for casual
    21     Sage usage.  Also, any code that uses this in the library would
    22     greatly slow down startup time, since currently there is no
    23     caching.
     14    - ``clang`` - may be either c or c++ indicating whether a C or C++
     15      compiler should be used.
     16
     17    - ``clib`` - additional libraries to be linked in, the space
     18      separated list is split and passed to distutils.
     19
     20    - ``cinclude`` - additional directories to search for header
     21      files. The space separated list is split and passed to
     22      distutils.
     23
     24    - ``cfile`` - additional C or C++ files to be compiled
     25
     26    - ``cargs`` - additional parameters passed to the compiler
     27
     28    For example::
     29
     30        #clang C++
     31        #clib givaro
     32        #cinclude /usr/local/include/
     33        #cargs -ggdb
     34        #cfile foo.c
    2435
    2536    AUTHOR: William Stein, 2006-10-31
    2637
    27     TODO: Need to create a clever caching system so code only gets
    28     compiled once.
     38    .. warn:
     39
     40        Only use this from Python code, not from extension code, since
     41        from extension code you would change the global scope (i.e.,
     42        of the Sage interpreter). And it would be stupid, since you're
     43        already writing Cython!
     44
     45        Also, never use this in the standard Sage library.  Any code
     46        that uses this can only run on a system that has a C compiler
     47        installed, and we want to avoid making that assumption for
     48        casual Sage usage.  Also, any code that uses this in the
     49        library would greatly slow down startup time, since currently
     50        there is no caching.
     51
     52    .. todo:
     53
     54        Need to create a clever caching system so code only gets
     55        compiled once.
    2956    """
    3057    tmpfile = sage.misc.misc.tmp_filename() + ".spyx"
    3158    open(tmpfile,'w').write(code)