From c4fa206b9579bb739a1cf9ceb7980b47a9b9c5e2 Mon Sep 17 00:00:00 2001
From: William Stein
Date: Sat, 28 Jul 2007 13:25:22 -0700
Subject: [PATCH] Initial version
---
CHANGES.txt | 1179 +++++++++++++++++++++++++++
COPYING.txt | 11 +
Demos/Makefile | 15 +
Demos/Makefile.nodistutils | 21 +
Demos/Setup.py | 13 +
Demos/callback/Makefile | 10 +
Demos/callback/Makefile.nodistutils | 19 +
Demos/callback/README.txt | 1 +
Demos/callback/Setup.py | 11 +
Demos/callback/cheese.pyx | 13 +
Demos/callback/cheesefinder.c | 21 +
Demos/callback/cheesefinder.h | 1 +
Demos/callback/run_cheese.py | 7 +
Demos/embed/Makefile | 30 +
Demos/embed/Makefile.msc | 35 +
Demos/embed/Makefile.msc.static | 1 +
Demos/embed/Makefile.unix | 30 +
Demos/embed/README | 1 +
Demos/embed/embedded.pyx | 5 +
Demos/embed/main.c | 9 +
Demos/numeric_demo.pyx | 39 +
Demos/primes.pyx | 18 +
Demos/pyprimes.py | 13 +
Demos/run_numeric_demo.py | 5 +
Demos/run_primes.py | 7 +
Demos/run_spam.py | 8 +
Demos/spam.pyx | 22 +
Doc/About.html | 1 +
Doc/FAQ.html | 77 ++
Doc/extension_types.html | 444 ++++++++++
Doc/index.html | 1 +
Doc/overview.html | 960 ++++++++++++++++++++++
Doc/primes.c | 1 +
Doc/sharing.html | 201 +++++
Doc/special_methods.html | 598 ++++++++++++++
INSTALL.txt | 22 +
LICENSE.txt | 50 ++
MANIFEST.in | 7 +
Makefile | 18 +
README.txt | 58 ++
ToDo.txt | 284 +++++++
Tools/pyrex-mode.el | 1 +
Tools/pyrex.st | 1 +
USAGE.txt | 69 ++
bin/cython | 8 +
bin/update_references | 49 ++
cython.py | 6 +
setup.py | 31 +
48 files changed, 4432 insertions(+)
create mode 100644 CHANGES.txt
create mode 100644 COPYING.txt
create mode 100644 Demos/Makefile
create mode 100644 Demos/Makefile.nodistutils
create mode 100644 Demos/Setup.py
create mode 100644 Demos/callback/Makefile
create mode 100644 Demos/callback/Makefile.nodistutils
create mode 100644 Demos/callback/README.txt
create mode 100644 Demos/callback/Setup.py
create mode 100644 Demos/callback/cheese.pyx
create mode 100644 Demos/callback/cheesefinder.c
create mode 100644 Demos/callback/cheesefinder.h
create mode 100644 Demos/callback/run_cheese.py
create mode 100644 Demos/embed/Makefile
create mode 100644 Demos/embed/Makefile.msc
create mode 100644 Demos/embed/Makefile.msc.static
create mode 100644 Demos/embed/Makefile.unix
create mode 100644 Demos/embed/README
create mode 100644 Demos/embed/embedded.pyx
create mode 100644 Demos/embed/main.c
create mode 100644 Demos/numeric_demo.pyx
create mode 100644 Demos/primes.pyx
create mode 100644 Demos/pyprimes.py
create mode 100644 Demos/run_numeric_demo.py
create mode 100644 Demos/run_primes.py
create mode 100644 Demos/run_spam.py
create mode 100644 Demos/spam.pyx
create mode 100644 Doc/About.html
create mode 100644 Doc/FAQ.html
create mode 100644 Doc/extension_types.html
create mode 100644 Doc/index.html
create mode 100644 Doc/overview.html
create mode 100644 Doc/primes.c
create mode 100644 Doc/sharing.html
create mode 100644 Doc/special_methods.html
create mode 100644 INSTALL.txt
create mode 100644 LICENSE.txt
create mode 100644 MANIFEST.in
create mode 100644 Makefile
create mode 100644 README.txt
create mode 100644 ToDo.txt
create mode 100644 Tools/pyrex-mode.el
create mode 100644 Tools/pyrex.st
create mode 100644 USAGE.txt
create mode 100644 bin/cython
create mode 100644 bin/update_references
create mode 100644 cython.py
create mode 100644 setup.py
diff --git a/CHANGES.txt b/CHANGES.txt
new file mode 100644
index 00000000..7cc0c506
--- /dev/null
+++ b/CHANGES.txt
@@ -0,0 +1,1179 @@
+0.9.4.1
+-------
+
+Bug fixes:
+
+ - Fixed indentation problem in Pyrex.Distutils.build_ext.
+ [Oliver Grisel ]
+
+
+0.9.4
+-----
+
+Improvements:
+
+ - All use of lvalue casts has been eliminated, for
+ compatibility with gcc4.
+
+ - PyMODINIT_FUNC now used to declare the module init function.
+
+ - Generated code should be compilable as either C or C++.
+ When compiling as C++, "extern C" is used where appropriate
+ to preserve linkage semantics. C++ functions still cannot
+ be called yet.
+
+ - An extension type can be made weak-referenceable by
+ giving it a C attribute of type object called __weakref__.
+
+ - Source files opened in universal newlines mode.
+
+ - Support for public extension type C attributes of type
+ long long and unsigned long long added (but not tested).
+ [Sam Rushing ]
+
+ - Distutils include directories now passed to Pyrex compiler.
+ [Konrad Hinsen ]
+
+ - Integer constants with an "L" suffix are now allowed
+ and are converted to Python long integers.
+ [Rainer Deyke ]
+
+ - A broken .c file is no longer left behind if there are
+ compilation errors.
+
+ - Using the result of a Python indexing or attribute access
+ operation as a char * is no longer considered an error in
+ most cases, as the former behaviour proved to be more
+ annoying than helpful.
+
+Bug fixes:
+
+ - Fixed problems with conversion from Python integers to
+ C unsigned longs. Now use PyInt_AsUnsignedLongMask and
+ PyInt_AsUnsignedLongLongMask instead of the PyLong_*
+ functions (which only work on Python longs).
+ [Wim Vree ]
+
+ - C unsigned ints now converted to/from Python longs intead
+ of Python ints to avoid overflow problems.
+ [Heiko Wundram ]
+
+ - Correct PyArg_ParseTuple format characters now used for
+ unsigned types. [Jeff Bowden ]
+
+ - Nonzero return value from a base class tp_traverse call
+ is handled.
+
+ - Taking sizeof an incomplete type caused a crash while
+ producing an error message. [Drew Perttula ]
+
+ - If a module cimported itself, definitions of global variables
+ were generated twice. [Parzival Herzog ]
+
+ - Distutils extension updated to handle changed signature of
+ swig_sources(). [David M. Cooke ]
+
+ - Incorrect C code generated for a raw string containing a double
+ quote preceded by a backslash. [Thomas Drake ]
+
+ - Declaration of public C function with an exception value written
+ to generated .pxi file without the except clause.
+ [Robby Dermody ]
+
+ - __delitem__ method of an extension type with no __setitem__
+ did not get called. [Richard Boulton ]
+
+ - A spurious Py_INCREF was generated when a return statement
+ required a type test. [Jonathan Doda ]
+
+ - Casting a value to a function pointer and then immediately
+ calling it generated a cast to a function instead of a cast
+ to a function pointer. [Simon Burton ]
+
+ - Py_TPFLAGS_HAVE_GC was not being set on an extension type that
+ inherited from an external extension type that used GC but did
+ not itself have any PyObject* attributes.
+ [Michael Hordijk ]
+
+ - A return statement inside a for statement leaked a reference
+ to the loop's iterator.
+ [Jürgen Kartnaller ]
+
+ - Full module name now appears in __module__ attribute of classes
+ and extension types, provided a correct dotted name is used
+ for the .pyx file. [Giovanni Bajo ]
+
+ - Public extension type with no C attributes produced an
+ invalid .pxi file. [Simon Burton ]
+
+ - Using a dict constructor as the second operand of a boolean
+ expression crashed the Pyrex compiler.
+ [Stefan Behnel ]
+
+ - A C declaration list ending with a comma resulted in invalid
+ C code being generated. [Alex Coventry ]
+
+ - A raw string containing two consecutive backslashes produced
+ incorrect C code. [Helmut Jarausch ]
+
+ - An error is reported if you attempt to declare a special
+ method of an extension type using 'cdef' instead of 'def'.
+ [Sam Rushing ]
+
+0.9.3
+-----
+
+Enhancements:
+
+ - Types defined with a ctypedef in a 'cdef extern from' block
+ are now referred to by the typedef name in generated C code,
+ so it is no longer necessary to match the type in the C
+ header file exactly.
+
+ - Conversion to/from unsigned long now done with
+ PyLong_AsUnsignedLong and PyLong_FromUnsignedLong.
+ [Dug Song ]
+
+ - A struct, union or enum definition in a 'cdef extern from'
+ block may now be left empty (using 'pass'). This can be useful
+ if you need to declare a variable of that type, but don't need
+ to refer to any of its members.
+
+ - More flexible about ordering of qualifiers such as 'long' and
+ 'unsigned'.
+ ["John (J5) Palmieri" ]
+
+
+Bug fixes:
+
+ - Non-interned string literals used in a Python class
+ definition did not work.
+ [Atsuo Ishimoto ]
+ [Andreas Kostyrka ]
+
+ - Return types of the buffer interface functions for extension
+ types have been corrected.
+ [Dug Song ]
+
+ - Added 'static' to declarations of string literals.
+ [Phil Frost ]
+
+ - Float literals are now copied directly to the C code as written,
+ to avoid problems with loss of precision.
+ [Mario Pernici ]
+
+ - Inheriting from an extension type with C methods defined in
+ another Pyrex module did not work.
+ [Itamar Shtull-Trauring ]
+
+0.9.2.1
+-------
+
+Bug fixes:
+
+ - Corrected an import statement setup.py, and made it
+ check for a unix platform in a more reliable way.
+
+0.9.2
+-----
+
+Enhancements:
+
+ - Names of Python global variables and attributes are now
+ interned, and PyObject_GetAttr/SetAttr are used instead
+ of PyObject_GetAttrString/SetAttrString. String literals
+ which resemble Python identifiers are also interned.
+
+ - String literals are now converted to Python objects only
+ once instead of every time they are used.
+
+ - NUL characters are now allowed in Python string literals.
+
+ - Added some missing error checking code to the beginning
+ of module init functions. It's unlikely the operations
+ involved would ever fail, but you never know.
+
+Bug fixes:
+
+ - Corrected some problems introduced by moving the Plex
+ package.
+
+0.9.1.1
+-------
+
+Bug fixes:
+
+ - Corrected a problem in the setup.py (pyrexc script incorrectly
+ named).
+
+ - Updated the distutils extension to match changes in the
+ Pyrex compiler calling interface.
+
+ - Doing 'make clean' in Demos/callback was removing a little too
+ much (that's why cheesefinder.c kept disappearing).
+
+0.9.1
+-----
+
+Enhancements:
+
+ - A C method can now call an inherited C method by the usual
+ Python technique.
+ [Jiba ]
+
+ - The __modname__ of a Python class is now set correctly.
+ [Paul Prescod ]
+
+ - A MANIFEST.in file has been added to the distribution to
+ facilitate building rpms.
+ [contributed by Konrad Hinsen ]
+
+Bug fixes:
+
+ - Conditional code now generated to allow for the renaming of LONG_LONG
+ to PY_LONG_LONG that occurred between Python 2.2 and 2.3.
+
+ - Header files referenced in cimported modules were not being included.
+ [Tom Popovich ]
+
+ - References to C functions and variables in a cimported module were
+ not being recognised if made from within a local scope.
+ [Tom Popovich ]
+
+ - Spurious declarations in code generated for a "finally" block.
+ [Brandon Long ]
+
+ - Attempting to return a value from a __contains__ method didn't work.
+ [Andreas Kostyrka ]
+
+ - Incorrect code generated for an extension type with C methods
+ inheriting from a base type with no C methods.
+ [Robin Becker ]
+
+ - Failure to report an error if a C method was defined in the
+ implementation part of an extension type that was not declared
+ in the corresponding definition part. Documentation also updated
+ to explain that this is necessary.
+ [Jiba ]
+
+ - Made it an error to forward-declare an extension type with
+ a different base class specification from its subsequent
+ definition.
+ [Jiba ]
+
+ - C attributes of an extension type were not being propagated
+ through more than one level of inheritance.
+ [Jiba ]
+
+ - If a garbage collection occurred early enough in the __new__
+ method of an extension type with Python-valued C attributes,
+ a crash could occur in its tp_traverse function.
+ [reported by Jiba ]
+ [fix suggested by Paul Prescod ]
+
+ - An empty vtable struct is no longer generated for extension
+ types with no C methods.
+ [Robin Becker ]
+
+ - Memory was leaked in the sq_item function of an extension
+ type with a __getitem__ method.
+ [Atsuo Ishimoto ]
+
+ - Code generated to work around a bug in some versions of Python
+ 2.2 which fails to initialise the tp_free slot correctly in
+ some circumstances.
+ [Matthias Baas ]
+
+ - Compiler crash when defining an extension type with a base
+ class specified by a dotted name.
+ [Alain Pointdexter ]
+
+ - Referencing an extension type defined in a cimported module
+ at run time did not work correctly.
+ [Alain Pointdexter ]
+
+ - Incorrect object struct code generated for an extension type
+ whose base class was defined in a .pxd file.
+ [Alain Pointdexter ]
+
+ - Redeclaring a type that wasn't previously an extension type
+ as an extension type caused a compiler crash.
+ [Scott Robinson ]
+
+ - Incorrect code was generated for return statements in a
+ special method with no return value.
+ [Gary Bishop ]
+
+ - Single-line def statement did not work.
+ [Francois Pinard ]
+
+Modifications:
+
+ - Only the last pathname component of the .pyx file is reported in
+ backtraces now.
+ [Bryan Weingarten ]
+
+ - Documentation corrected to remove the erroneous statement that
+ extension classes can have a __del__ method.
+ [Bryan Weingarten ]
+
+ - Note added to documentation explaining that it is not possible
+ for an extension type's __new__ method to explicitly call the
+ inherited __new__ method.
+
+ - The version of Plex included with Pyrex is now installed
+ as a subpackage of the Pyrex package, rather than as a
+ top-level package, so as not to interfere with any other
+ version of Plex the user may have installed.
+
+0.9
+---
+
+New features:
+
+ - Extension types can have properties. See the new "Properties"
+ section in the "Extension Types" page.
+
+ - An extension type can inherit from a builtin type or another
+ extension type. See "Subclassing" in the "Extension Types" page.
+
+ - Extension types can have C methods, which can be overridden
+ in derived extension types. See "C Methods" in the "Extension Types"
+ page.
+
+Enhancements:
+
+ - Conversion is now performed between C long longs and Python
+ long integers without chopping to the size of a C long.
+ Also the Python PY_LONG_LONG type is now used for long longs
+ for greater portability.
+
+Bug fixes:
+
+ - Names were sometimes being generated that were insufficiently
+ unique in the presence of cimported declarations.
+
+ - Changed the way the included filename table is declared from
+ char *[] to char **, to stop MSVC from complaining about it
+ having an unknown size.
+ [Alexander A Naanou ]
+
+ - Second argument of assert statement was not being coerced
+ to a Python value.
+ [Francois Pinard http://www.iro.umontreal.ca/~pinard]
+
+ - Return statement without value wasn't accepted in some
+ extension type special methods when it should have been.
+ [Francois Pinard http://www.iro.umontreal.ca/~pinard]
+
+ - Attempting to call a non-function C value crashed the
+ compiler.
+ [John J Lee ]
+
+ - Functions declared as "except *" were not returning exceptions.
+ [John J Lee ]
+
+ - A syntax warning from Plex about assignment to None has
+ been eliminated.
+ [Gordon Williams ]
+
+ - Public function declaration with empty argument list was
+ producing (void) in .pxi file.
+ [Michael P. Dubner ]
+
+ - Incorrect error signalling code was being generated in the
+ __hash__ special method of an extension type.
+
+
+0.8.1
+-----
+
+Bug fixes:
+
+ - Names of structs, unions and enums in external header
+ files were getting mangled when they shouldn't have been.
+ [Norman Shelley ]
+
+ - Modified distutils extension so that it will stop before
+ compiling the C file if the Pyrex compiler reports errors.
+ [John J Lee ]
+
+
+0.8
+---
+
+New features:
+
+ - INCOMPATIBLE CHANGE: The type object of an external extension
+ type is now imported at run time using the Python import
+ mechanism. To make this possible, an 'extern' extension type
+ declaration must DECLARE THE MODULE from which the extension
+ type originates. See the new version of the "Extension Types"
+ documentation for details.
+
+ This change was made to eliminate the need for Pyrex to be
+ told the C name of the type object, or for the Pyrex module
+ to be linked against the object code providing the type object.
+
+ You will have to update any existing external extension type
+ declarations that you are using. I'm sorry about that, but it
+ was too hard to support both the old and new ways.
+
+ - Compile-time importing: A Pyrex module can now import declarations
+ from another Pyrex module using the new 'cimport' statement. See
+ the new section on "Sharing Declarations Between Pyrex Modules" in
+ the documentation.
+
+Minor improvements:
+
+ - An error is reported if you declare a struct, union or
+ extension type using 'cdef' in one place and 'ctypedef'
+ in another.
+
+ - Struct, union and extension types can only be forward-
+ declared using 'cdef', not 'ctypedef' (otherwise invalid
+ C code would be generated).
+
+ - The 'global' statement can be used at the module level to
+ declare that a name is a module-level name rather than a
+ builtin. This can be used to access module attributes such
+ as __name__ that would otherwise be assumed to be builtins.
+ [Pat Maupin ]
+
+ - The 'assert' statement now accepts a second argument.
+ [Francois Pinard ]
+
+Bug fixes:
+
+ - When using Python 2.3, "True" or "False" could sometimes
+ turn up in generated code instead of "1" or "0".
+ [Adam Hixson ]
+
+ - Function return value not always converted to or from a
+ Python object when it should have been.
+
+ - Certain kinds of error in a function call expression
+ could crash the compiler.
+ ["Edward C. Jones" ]
+
+ - Fixed memory leak in functions with * or ** args.
+ [Alexander A Naanou ]
+
+
+0.7.1
+-----
+
+Bug fixes:
+
+ - Calling a function declared as returning an extension
+ type could crash the compiler.
+
+ - A function call with type errors in the argument list
+ could crash the compiler.
+
+ - An 'else' clause on a for-from statement could crash
+ the compiler.
+
+ - Incorrect casting code was generated when a generic
+ object argument of a special method was declared as
+ being of an extension type.
+ [Phillip J. Eby ]
+
+ - A blank line that couldn't be interpreted wholly as
+ a valid indentation sequence caused a syntax error.
+ In particular, a formfeed character on an otherwise
+ blank line wasn't accepted.
+ [Francois Pinard ]
+
+ - Parallel assignments were incorrectly optimised.
+
+ - A bare tuple constructor with an extra comma at the
+ end of a line caused a syntax error.
+
+0.7
+---
+
+New features:
+
+ - Attributes of extension types can be exposed to Python
+ code, either read/write or read-only.
+
+ - Different internal and external names can be specified
+ for C entities.
+
+ - None is a compile-time constant, and more efficient code
+ is generated to reference it.
+
+ - Command line options for specifying directories to
+ search for include files.
+
+Enhancements:
+
+ - More efficient code is generated for access to Python
+ valued C attributes of extension types.
+
+ - Cosmetic code improvement: Less casting back and forth
+ between extension types and PyObject * when referencing
+ C members of the object struct.
+
+ - C arguments and variables declared as an extension type
+ can take the value None.
+
+ - Form feed characters are accepted as whitespace.
+
+ - Function names in tracebacks are qualified with
+ module name and class name.
+
+Bug fixes:
+
+ - A sufficiently complex expression in a boolean context
+ could cause code to be generated twice for the same
+ subexpression.
+
+ - Incorrect casting code was generated when passing an
+ extension type to a function expecting a generic Python
+ object.
+
+ - Executable statements are now disallowed inside a
+ cdef class block (previously they silently caused
+ crazy C code to be generated).
+
+ - Tracebacks should now report the correct filename for
+ functions defined in files included with the 'include'
+ statement.
+
+ - The documentation incorrectly claimed that an extension
+ type can't have a __del__ method. In fact, it can, and
+ it behaves as expected.
+
+
+0.6.1
+-----
+
+Bug fixes:
+
+ - Fixed broken distutils extension.
+
+
+
+0.6
+---
+
+New features:
+
+ - Command line options for reporting version number,
+ requesting a listing file and specifying the name of
+ the generated C file.
+
+ - An 'include' statement allows inclusion of declarations
+ from other Pyrex source files.
+
+ - If there are any public declarations, a Pyrex include
+ file is generated (as well as a .h file) containing
+ declarations for them.
+
+ - Extension types can be declared public, so their C
+ attributes are visible to other Pyrex and C code.
+
+ - Try-except statements can now have an 'else' clause.
+ [Francois Pinard ]
+
+ - Multiple simple statements can be placed on one line
+ separated by semicolons.
+
+ - A suite consisting of a simple statement list can now
+ be placed on the same line after the colon in most
+ cases.
+ [Francois Pinard ]
+
+ - The automatic coercion of a C string to a C char has
+ been removed (it proved to be too error-prone).
+ Instead, there is a new form of literal for C
+ character constants: c'X'
+
+ - The __get__ special method (used by descriptor objects)
+ now allows for the possibility of the 2nd or 3rd
+ arguments being NULL. Also the __set__ method has been
+ split into two methods, __set__ and __delete__.
+ [Phillip J. Eby ]
+
+Bug fixes:
+
+ - Values unpacked into a non-Python destination variable
+ were not being converted before assignment.
+ [Gareth Watts ]
+
+ - Hex constants greater than 0x7fffffff caused compiler
+ to crash. [Gareth Watts ]
+
+ - Type slots are no longer statically initialised with
+ extern function pointers, to avoid problems with
+ some compilers. The hack in the distutils extension
+ to work around this by compiling as C++ has been
+ disabled. [Phillip J. Eby ]
+
+ - Fixed several more instances of the error-reporting
+ routine being called with arguments in the wrong
+ order. Hoping I've *finally* got all of them now...
+
+ - Nested for-from loops used the same control variable.
+ [Sebastien de Menten ]
+
+ - Fixed some other error message related bugs.
+ [Francois Pinard ]
+
+ - Assigning to slice didn't work.
+ [Francois Pinard ]
+
+ - Temp variables were being declared as extension
+ types and then being assigned PyObject *'s. All
+ Python temp vars are now declared as PyObject *.
+ [Francois Pinard ]
+
+0.5
+---
+
+Bug fixes:
+
+ - Algorithm for allocating temp variables redesigned
+ to fix various errors concerning temp
+ variable re-use.
+ [Mark Rowe ]
+
+ - Memory leak occured sometimes when an implicit
+ type test was applied to the result of an
+ expression.
+ [christoph.wiedemann@daimlerchrysler.com]
+
+ - __set__ method of extension types had wrong
+ signature.
+ [Josh Littlefield ]
+
+0.4.6
+-----
+
+Bug fixes:
+
+ - Indexing multi-dimensional C arrays didn't
+ work.
+ [Gary Dietachmayer ]
+
+
+0.4.5
+-----
+
+New features:
+
+ - There is now a 'public' declaration for
+ making Pyrex-defined variables and functions
+ available to external C code. A .h file is
+ also generated if there are any public
+ declarations.
+
+Enhancements:
+
+ - Defining __len__/__getitem__ methods in an
+ extension class fills sq_length/sq_item slots
+ as well as mp_length/mp_subscript.
+ [Matthias Baas ]
+
+ - The Distutils extension now allows .c files
+ to be incorporated along with .pyx files.
+ [Modification to Distutils extension contributed
+ by Darrell Gallion .]
+
+Bug fixes:
+
+ - Float literals without a decimal point
+ work again now.
+ [Mike Rovner ]
+ [Peter Lepage ]
+
+ - Compiler crashed if exception value didn't
+ match function return type.
+ [Michael JasonSmith ]
+
+ - The setup.py file should now install the
+ Lexicon.pickle file in the right place.
+ [Patch supplied by David M. Cooke
+ ]
+
+ - Compiler crashed when compiling a C function that
+ returned an extension type.
+ [David M. Cooke
+ ]
+
+ - Anonymous enum types did not have C code
+ suppressed inside an extern-from block.
+ [Matthew Mueller ]
+
+
+0.4.4
+-----
+
+Enhancements:
+
+ - Tracebacks now extend into Pyrex function
+ calls and show line numbers in the Pyrex
+ source file.
+
+ - Syntax for float literals made more lenient
+ (no longer requires digits both before and
+ after the point).
+ [Peter Lepage ]
+
+ - Method calls can be made on string literals
+ (e.g. ",".join(x)).
+ [pedro_rodriguez@club-internet.fr]
+
+Bug fixes:
+
+ - Incorrect refcount code generated when a
+ Python function needing argument type tests
+ had local Python variables.
+ [Matthias Baas ]
+
+ - 'self' parameter of __getitem__ method of
+ extension type had wrong implicit type.
+ [Peter Lepage ]
+
+ - Repaired breakage introduced by trying to
+ allow an empty parameter list to be written
+ as (void). No longer attempting to allow
+ this (too hard to parse correctly).
+ [Peter Lepage ]
+
+ - Found bug in Plex 1.1.2 which was the *real*
+ cause of the two-newlines-in-a-row problem.
+ Removed the Opt(Eol)+Str("\n") hacks in
+ the scanner which were working around this
+ before.
+ [pedro_rodriguez@club-internet.fr]
+
+ - __call__ special method of extension types
+ had wrong signature.
+ [Peter Lepage ]
+
+
+0.4.3
+-----
+
+New language features:
+
+ - For-from loop for iterating over integer
+ ranges, using pure C loop where possible.
+
+Enhancements:
+
+ - sizeof() can now be applied to types as
+ well as variables.
+
+ - Improved handling of forward-declared
+ extension types.
+
+Bug fixes:
+
+ - Two newlines in a row in a triple quoted
+ string caused a parse error on some
+ platforms.
+ [Matthias Baas ]
+
+ - Fixed problem with break and continue in
+ the else-clause of a loop.
+
+
+0.4.2
+-----
+
+New language features:
+
+ - C functions can be declared as having an
+ exception return value, which is checked
+ whenever the function is called. If an
+ exception is detected inside a C function
+ for which no exception value is declared,
+ a warning message is printed and the
+ exception is cleared.
+
+ - Cascaded assignments (i.e. a = b = c
+ are now supported.
+
+ - Anonymous enum declarations are allowed,
+ for when you just want to declare constants.
+
+ - The C types "long long" and "long double"
+ are now understood. Also, "int" is optional
+ after "short" or "long".
+
+Enhancements:
+
+ - A * argument in a function call can now be
+ any sequence, not just a tuple.
+
+ - A C char* or char[] will be turned into
+ a char by taking its first character if
+ used in a context where a char is required,
+ thus allowing a string literal to be used as
+ a char literal.
+
+ - C string * C int or vice versa is now
+ interpreted as Python string replication.
+
+ - Function arguments are checked for void or
+ incomplete type.
+
+Bug fixes:
+
+ - Non-external extension types show up in the
+ module dict once more (this got broken in
+ 0.4.1).
+
+ - A spurious decref has been removed from the
+ runtime support code for the "import" statement.
+ Hopefully this will prevent the crashes some
+ people have been experiencing when importing
+ builtin modules.
+ [Mathew Yeates ]
+
+0.4.1
+-----
+
+New language features:
+
+ - "ctypedef struct/union/enum/class" statements
+ added, for use in extern-from blocks when a
+ header file uses a ctypedef to declare a
+ tagless struct, union or enum type.
+
+ - "pass" allowed in an extern-from block.
+
+ - "cdef extern from *" for when you don't want
+ to specify an include file name.
+
+ - Argument names may be omitted in function
+ signatures when they're not needed.
+
+ - New reserved word NULL for the null C pointer.
+
+Compiler enhancements:
+
+ - Lexicon is now picked in binary format, so
+ startup should be much faster on slower
+ machines.
+
+ - If Pyrex decides to rebuild the lexicon and
+ then finds that it can't write a pickle file,
+ it now prints a warning and carries on
+ instead of crashing.
+
+ - Chat about hash codes and lexicon pickling
+ now turned off by default except when creating
+ a new lexicon (which ought never happen now
+ unless you change the scanner).
+
+Bug fixes:
+
+ - Modified the runtime support code for "import"
+ statements, hopefully fixing problem with using
+ a Pyrex module in conjunction with py2exe.
+
+ - DL_EXPORT now used in both the prototype and
+ definition of the module init function.
+
+ - Exception state is now saved and restored around
+ calls to an extension type __dealloc__ method,
+ to avoid screwing up if the object is deallocated
+ while an exception is being propagated.
+
+ - Making an attribute reference to a method of
+ an extension type caused a compiler crash.
+
+ - Doc string in new-style class definition
+ caused a run-time error.
+
+ - Insufficient parentheses were put around C type
+ casts.
+
+ - Constructors for extension types are now read-only
+ C global variables instead of entries in the
+ module dict. This change was needed to prevent
+ Numeric from blowing up due to touching its
+ typeobject before import_numeric() could be called.
+
+0.4
+---
+
+New features:
+
+ - "cdef extern from" statement allows inclusion
+ of C header files to be specified, solving
+ a number of problems including:
+ - Clashes between Pyrex and C declarations,
+ due to "const" and other reasons
+ - Windows-specific features required in
+ function declarations
+ - Helping deal with types such as "size_t"
+ - Helping deal with functions defined as
+ macros
+
+ - Access to internals of pre-existing extension
+ types is now possible by placing an extension
+ type declaration inside a "cdef extern from"
+ block.
+
+Bug fixes:
+
+ - Error not reported properly when passing
+ wrong number of args to certain special
+ methods of extension types.
+ [Mitch Chapman ]
+
+ - Compile-time crash when defining an extension
+ type with a __hash__ method.
+
+Minor enhancements:
+
+ - Hashing of the scanner source file made more
+ platform-independent, making spurious regeneration
+ of the pickle less likely.
+
+
+0.3.4
+-----
+
+Bug fixes:
+
+ - Runtime crash when using * or ** args in
+ a method of an extension type fixed.
+ [Matthew Mueller ]
+
+ - Compiler crash when using default argument
+ values in a method of a Python class.
+ [Mike Rovner ]
+
+Enhancements:
+
+ - Type slots filled with functions from outside
+ the extension module are now initialised dynamically,
+ which should eliminate at least some of the
+ "initialiser is not constant" problems experienced
+ on Windows.
+ [Marek Baczek ]
+
+ - On Windows, __declspec(dllexport) is now used for
+ the module init func declaration (or should be --
+ I haven't tested this).
+ [Marek Baczek ]
+
+ - The compiler shouldn't attempt to rewrite the
+ Lexicon.pickle file unless the source has been
+ changed (hashing is used now instead of comparing
+ timestamps). So there should be no problem any more
+ with installing Pyrex read-only.
+ [fawcett@uwindsor.ca]
+
+0.3.3
+-----
+
+Bug fixes:
+
+* A void * can be assigned from any other
+pointer type.
+[piers@cs.su.oz.au]
+
+* File names in error messages no longer
+quoted (this was apparently confusing some
+editors).
+[donut@azstarnet.com]
+
+* Reference to a struct member which is an
+array is coerced to a pointer.
+[donut@azstarnet.com]
+
+* Default argument values did not work
+in methods of an extension type.
+[donut@azstarnet.com]
+
+* Single or double quote characters in a
+triple-quoted string didn't work.
+[donut@azstarnet.com]
+
+* Using *args in a function definition
+sometimes caused a crash at runtime.
+[donut@azstarnet.com]
+
+* A hack is included which tries to make
+functions in Python.h which use 'const'
+accessible from Pyrex. But it doesn't
+work on all platforms. Thinking about a
+better solution.
+
+
+New features:
+
+* Comment containing Pyrex version number
+and date/time at top of generated C file.
+[baas@ira.uka.de]
+
+
+0.3.2
+-----
+
+Bug fixes:
+
+* The & operator works again.
+[matthias.oberlaender@daimlerchrysler.com]
+[baas@ira.uka.de]
+
+* The & operator had incorrect precedence.
+
+* "SystemError: 'finally' pops bad exception"
+under some circumstances when raising an
+exception. [baas@ira.uka.de]
+
+* Calling a Python function sometimes leaked
+a reference.
+
+* Crash under some circumstances when casting
+a Python object reference to a C pointer type.
+[mpj17@cosc.canterbury.ac.nz]
+
+* Crash when redeclaring a function.
+[baas@ira.uka.de]
+
+* Crash when using a string constant inside
+a Python class definition.
+[mike@bindkey.com]
+
+* 2-element slice indexing expressions.
+[mike@bindkey.com]
+
+* Crash when encountering mixed tabs and
+spaces.
+[mike@bindkey.com]
+
+New features:
+
+* A wider variety of constant expressions is
+now accepted for enum values, array
+dimensions, etc.
+[mike@bindkey.com]
+
+
+0.3.1
+-----
+
+New features:
+
+* More special methods for extension types:
+__delitem__, __delslice__, __getattr__,
+__setattr__, __delattr__
+
+* Module-level variable of a Python object type
+declared with 'cdef' is private to the module, and
+held in a C variable instead of the module dict.
+
+* External C functions with variable argument lists
+can be declared and called.
+
+* Pyrex-defined Python functions can have default
+argument values and * and ** arguments, and can be
+called with keyword arguments.
+
+* Pointer-to-function types can be declared.
+
+* Pyrex now supports a declaration syntax that
+C doesn't! Example:
+
+ cdef (int (*)()) foo() # function returning a function ptr
+
+* There is now a ctypedef statement.
+
+* Extension types can now be forward-declared.
+
+* All permutations of (non-Unicode) string literals
+and escape codes should work now.
+
+* Hex and octal integer literals.
+
+* Imaginary number literals.
+
+* Docstrings are now supported.
+
+Bug fixes:
+
+* Type tests are performed when using a Python object
+in a context requiring a particular extension type.
+
+* Module-level variable holding the type object
+of an extension type had incorrect type.
+
+0.3
+---
+
+New features:
+
+* Extension types! Yay!
+
+0.2.2
+-----
+
+Bug fixes:
+
+* Fixed error message generation again after a previous
+bug was accidentally re-indroduced.
+
+* Removed the declaration of isspace() from the code
+generated for print statement support (it's not needed
+and was conflicting with the system-supplied one on
+some platforms).
+
+0.2
+---
+
+New features:
+
+* Executable statements are now allowed at the
+top level of a module.
+
+* Python class definitions are now supported, with
+the following limitations:
+
+ - Class definitions are only allowed at the top
+ level of a module, not inside a control structure
+ or function or another class definition.
+
+ - Assigning a Pyrex-defined Python function to a
+ class attribute outside of the class definition
+ will not create a method (because it's not an
+ interpreted Python function and therefore
+ won't trigger the bound-method creation magic).
+
+ - The __metaclass__ mechanism and the creation of
+ new-style classes is not (yet) supported.
+
+* Casting between Python and non-Python types is
+better supported.
+
+Bug fixes:
+
+* Fixed bug preventing for-loops from working.
+
+
+0.1.1
+-----
+
+* I've discovered a flaw in my algorithm for releasing
+temp variables. Fixing this properly will require some
+extensive reworking; I've put in a hack in the meantime
+which should work at the cost of using more temp variables
+than are strictly necessary.
+
+* Fixed bug preventing access to builtin names from
+working. This should also have fixed the import
+statement, but I haven't tested it.
+
+* Fixed some errors in __Pyx_GetExcValue.
+
+* Fixed bug causing boolean expressions to malfunction
+sometimes.
diff --git a/COPYING.txt b/COPYING.txt
new file mode 100644
index 00000000..f266bada
--- /dev/null
+++ b/COPYING.txt
@@ -0,0 +1,11 @@
+The original Pyrex code as of 2006-04 is licensed under the following
+license: "Copyright stuff: Pyrex is free of restrictions. You may use,
+redistribute, modify and distribute modified versions."
+
+------------------
+
+Cython, which derives from Pyrex, is licensed under the Python
+Software Foundation License. More precisely, all modifications
+made to go from Pyrex to Cython are so licensed.
+
+
diff --git a/Demos/Makefile b/Demos/Makefile
new file mode 100644
index 00000000..e70687f4
--- /dev/null
+++ b/Demos/Makefile
@@ -0,0 +1,15 @@
+all:
+ python Setup.py build_ext --inplace
+
+test: all
+ python run_primes.py 20
+ python run_numeric_demo.py
+ python run_spam.py
+ cd callback; $(MAKE) test
+
+clean:
+ @echo Cleaning Demos
+ @rm -f *.c *.o *.so *~ core
+ @rm -rf build
+ @cd callback; $(MAKE) clean
+ @cd embed; $(MAKE) clean
diff --git a/Demos/Makefile.nodistutils b/Demos/Makefile.nodistutils
new file mode 100644
index 00000000..d648f849
--- /dev/null
+++ b/Demos/Makefile.nodistutils
@@ -0,0 +1,21 @@
+PYHOME = $(HOME)/pkg/python/version
+PYINCLUDE = \
+ -I$(PYHOME)/include/python2.2 \
+ -I$(PYHOME)/$(ARCH)/include/python2.2
+
+%.c: %.pyx
+ ../bin/pyrexc $<
+
+%.o: %.c
+ gcc -c -fPIC $(PYINCLUDE) $<
+
+%.so: %.o
+ gcc -shared $< -lm -o $@
+
+all: primes.so spam.so numeric_demo.so
+
+clean:
+ @echo Cleaning Demos
+ @rm -f *.c *.o *.so *~ core core.*
+ @cd callback; $(MAKE) clean
+ @cd embed; $(MAKE) clean
diff --git a/Demos/Setup.py b/Demos/Setup.py
new file mode 100644
index 00000000..658a44c3
--- /dev/null
+++ b/Demos/Setup.py
@@ -0,0 +1,13 @@
+from distutils.core import setup
+from distutils.extension import Extension
+from Pyrex.Distutils import build_ext
+
+setup(
+ name = 'Demos',
+ ext_modules=[
+ Extension("primes", ["primes.pyx"]),
+ Extension("spam", ["spam.pyx"]),
+ Extension("numeric_demo", ["numeric_demo.pyx"]),
+ ],
+ cmdclass = {'build_ext': build_ext}
+)
diff --git a/Demos/callback/Makefile b/Demos/callback/Makefile
new file mode 100644
index 00000000..890bc808
--- /dev/null
+++ b/Demos/callback/Makefile
@@ -0,0 +1,10 @@
+all:
+ python Setup.py build_ext --inplace
+
+test: all
+ python run_cheese.py
+
+clean:
+ @echo Cleaning Demos/callback
+ @rm -f cheese.c *.o *.so *~ core
+ @rm -rf build
diff --git a/Demos/callback/Makefile.nodistutils b/Demos/callback/Makefile.nodistutils
new file mode 100644
index 00000000..012c1a86
--- /dev/null
+++ b/Demos/callback/Makefile.nodistutils
@@ -0,0 +1,19 @@
+PYHOME = $(HOME)/pkg/python/version
+PYINCLUDE = \
+ -I$(PYHOME)/include/python2.2 \
+ -I$(PYHOME)/$(ARCH)/include/python2.2
+
+%.c: %.pyx
+ ../../bin/pyrexc $<
+
+%.o: %.c
+ gcc -c -fPIC $(PYINCLUDE) $<
+
+%.so: %.o
+ gcc -shared $< -lm -o $@
+
+all: cheese.so
+
+clean:
+ @echo Cleaning Demos/callback
+ @rm -f *.c *.o *.so *~ core core.*
diff --git a/Demos/callback/README.txt b/Demos/callback/README.txt
new file mode 100644
index 00000000..fa3b871c
--- /dev/null
+++ b/Demos/callback/README.txt
@@ -0,0 +1 @@
+This example demonstrates how you can wrap a C API
that has a callback interface, so that you can
pass Python functions to it as callbacks.
The files cheesefinder.h and cheesefinder.c
represent the C library to be wrapped.
The file cheese.pyx is the Pyrex module
which wraps it.
The file run_cheese.py demonstrates how to
call the wrapper.
\ No newline at end of file
diff --git a/Demos/callback/Setup.py b/Demos/callback/Setup.py
new file mode 100644
index 00000000..5e48206a
--- /dev/null
+++ b/Demos/callback/Setup.py
@@ -0,0 +1,11 @@
+from distutils.core import setup
+from distutils.extension import Extension
+from Pyrex.Distutils import build_ext
+
+setup(
+ name = 'callback',
+ ext_modules=[
+ Extension("cheese", ["cheese.pyx", "cheesefinder.c"]),
+ ],
+ cmdclass = {'build_ext': build_ext}
+)
diff --git a/Demos/callback/cheese.pyx b/Demos/callback/cheese.pyx
new file mode 100644
index 00000000..db0fc082
--- /dev/null
+++ b/Demos/callback/cheese.pyx
@@ -0,0 +1,13 @@
+#
+# Pyrex wrapper for the cheesefinder API
+#
+
+cdef extern from "cheesefinder.h":
+ ctypedef void (*cheesefunc)(char *name, void *user_data)
+ void find_cheeses(cheesefunc user_func, void *user_data)
+
+def find(f):
+ find_cheeses(callback, f)
+
+cdef void callback(char *name, void *f):
+ (
+
+
+
Accessing Python/C API routines
+
+ One particular use of the cdef extern from statement is for gaining
+ access to routines in the Python/C API. For example,
+
cdef extern from "Python.h":
+
object PyString_FromStringAndSize(char *s, int len)
+
+
+ will allow you to create Python strings containing null bytes.
+
+
+
+
+
Resolving naming conflicts - C name specifications
+
+ Each Pyrex module has a single module-level namespace for both Python
+and C names. This can be inconvenient if you want to wrap some external
+C functions and provide the Python user with Python functions of the same
+names.
+
Pyrex 0.8 provides a couple of different ways of solving this problem.
+ The best way, especially if you have many C functions to wrap, is probably
+ to put the extern C function declarations into a different namespace using
+ the facilities described in the section on sharing
+ declarations between Pyrex modules.
+
+
+
The other way is to use a c name specification to give different
+ Pyrex and C names to the C function. Suppose, for example, that you want
+to wrap an external function called eject_tomato. If you declare
+it as
+
+ then its name inside the Pyrex module will be c_eject_tomato,
+whereas its name in C will be eject_tomato. You can then wrap it
+with
+
def eject_tomato(speed): c_eject_tomato(speed)
+
+
+ so that users of your module can refer to it as eject_tomato.
+
+
Another use for this feature is referring to external names that happen
+ to be Pyrex keywords. For example, if you want to call an external function
+ called print, you can rename it to something else in your Pyrex
+module.
+
+
+
As well as functions, C names can be specified for variables, structs,
+ unions, enums, struct and union members, and enum values. For example,
+
+
+
cdef extern int one "ein", two "zwei" cdef extern float three "drei"
cdef struct spam "SPAM": int i "eye"
+ cdef enum surprise "inquisition":
+ first "alpha"
+ second "beta" = 3
+
+
+
+
Public Declarations
+
+ You can make C variables and functions defined in a Pyrex module accessible
+ to external C code (or another Pyrex module) using the public keyword, as follows:
+
cdef public int spam # public variable declaration
cdef public void grail(int num_nuns): # public function declaration
+ ...
+
+
+ If there are any public declarations in a Pyrex module, a .h file is generated containing equivalent C declarations for inclusion in other
+ C code.
+
Pyrex also generates a .pxi file containing Pyrex versions of the
+ declarations for inclusion in another Pyrex module using the include statement. If you use this, you
+ will need to arrange for the module using the declarations to be linked
+against the module defining them, and for both modules to be available to
+the dynamic linker at run time. I haven't tested this, so I can't say how
+well it will work on the various platforms.
+
+ One of the most powerful features of Pyrex is the ability to easily create
+ new built-in Python types, called extension types. This is a major
+ topic in itself, so there is a separate
+ page devoted to it.
+
Sharing Declarations Between Pyrex Modules
+
+
+ Pyrex 0.8 introduces a substantial new set of facilities allowing a Pyrex
+ module to easily import and use C declarations and extension types from another
+Pyrex module. You can now create a set of co-operating Pyrex modules just
+as easily as you can create a set of co-operating Python modules. There is
+a separate page devoted to this topic.
+
Limitations
+
+
+
+
Unsupported Python features
+
+ Pyrex is not quite a full superset of Python. The following restrictions
+ apply:
+
Function definitions (whether using def or cdef)
+ cannot be nested within other function definitions.
+
+
Class definitions can only appear at the top level of a module,
+ not inside a function.
+
+
The import * form of import is not allowed anywhere
+ (other forms of the import statement are fine, though).
+
+
Generators cannot be defined in Pyrex.
+
+
+
The globals() and locals() functions cannot be
+used.
+
+
+ The above restrictions will most likely remain, since removing them would
+ be difficult and they're not really needed for Pyrex's intended applications.
+
+
There are also some temporary limitations, which may eventually be lifted, including:
+
+
+
+
Class and function definitions cannot be placed inside
+control structures.
+
+
In-place arithmetic operators (+=, etc) are not yet supported.
+
+
List comprehensions are not yet supported.
+
+
There is no support for Unicode.
+
+
Special methods of extension types cannot have functioning
+docstrings.
+
+
+
The use of string literals as comments is not recommended at present,
+ because Pyrex doesn't optimize them away, and won't even accept them in
+places where executable statements are not allowed.
+
+
+
Semantic differences between Python
+ and Pyrex
+
+
+
Behaviour of class scopes
+
+ In Python, referring to a method of a class inside the class definition,
+ i.e. while the class is being defined, yields a plain function object, but
+ in Pyrex it yields an unbound method2. A consequence of this is that the
+usual idiom for using the classmethod and staticmethod functions, e.g.
+
class Spam:
+
def method(cls): ...
+
method = classmethod(method)
+
+
+ will not work in Pyrex. This can be worked around by defining the function
+ outside the class, and then assigning the result of classmethod or
+ staticmethod inside the class, i.e.
+
def Spam_method(cls): ...
+
class Spam:
+
method = classmethod(Spam_method)
+
+
+
+
Footnotes
+
+ 1. A problem with const could arise if you have
+something like
+
cdef extern from "grail.h": char *nun
+
+
+ where grail.h actually contains
+
extern const char *nun;
+
+
+ and you do
+
cdef void languissement(char *s): #something that doesn't change s
+
...
+
languissement(nun)
+
+
+ which will cause the C compiler to complain. You can work around it by
+casting away the constness:
+
languissement(<char *>nun)
+
+
+
+2. The reason for the different behaviour
+of class scopes is that Pyrex-defined Python functions are PyCFunction objects,
+not PyFunction objects, and are not recognised by the machinery that creates
+a bound or unbound method when a function is extracted from a class. To get
+around this, Pyrex wraps each method in an unbound method object itself before
+storing it in the class's dictionary.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Doc/primes.c b/Doc/primes.c
new file mode 100644
index 00000000..9a88b84c
--- /dev/null
+++ b/Doc/primes.c
@@ -0,0 +1 @@
+#include "Python.h"
static PyObject *__Pyx_UnpackItem(PyObject *, int);
static int __Pyx_EndUnpack(PyObject *, int);
static int __Pyx_PrintItem(PyObject *);
static int __Pyx_PrintNewline(void);
static void __Pyx_ReRaise(void);
static void __Pyx_RaiseWithTraceback(PyObject *, PyObject *, PyObject *);
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list);
static PyObject *__Pyx_GetExcValue(void);
static PyObject *__Pyx_GetName(PyObject *dict, char *name);
static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
PyObject *__pyx_f_primes(PyObject *__pyx_self, PyObject *__pyx_args); /*proto*/
PyObject *__pyx_f_primes(PyObject *__pyx_self, PyObject *__pyx_args) {
int __pyx_v_kmax;
int __pyx_v_n;
int __pyx_v_k;
int __pyx_v_i;
int (__pyx_v_p[1000]);
PyObject *__pyx_v_result;
PyObject *__pyx_r;
PyObject *__pyx_1 = 0;
int __pyx_2;
int __pyx_3;
int __pyx_4;
PyObject *__pyx_5 = 0;
PyObject *__pyx_6 = 0;
if (!PyArg_ParseTuple(__pyx_args, "i", &__pyx_v_kmax)) return 0;
__pyx_v_result = Py_None; Py_INCREF(__pyx_v_result);
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":2 */
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":3 */
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":4 */
__pyx_1 = PyList_New(0); if (!__pyx_1) goto __pyx_L1;
Py_DECREF(__pyx_v_result);
__pyx_v_result = __pyx_1;
__pyx_1 = 0;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":5 */
__pyx_2 = (__pyx_v_kmax > 1000);
if (__pyx_2) {
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":6 */
__pyx_v_kmax = 1000;
goto __pyx_L2;
}
__pyx_L2:;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":7 */
__pyx_v_k = 0;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":8 */
__pyx_v_n = 2;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":9 */
while (1) {
__pyx_L3:;
__pyx_2 = (__pyx_v_k < __pyx_v_kmax);
if (!__pyx_2) break;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":10 */
__pyx_v_i = 0;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":11 */
while (1) {
__pyx_L5:;
if (__pyx_3 = (__pyx_v_i < __pyx_v_k)) {
__pyx_3 = ((__pyx_v_n % (__pyx_v_p[__pyx_v_i])) != 0);
}
if (!__pyx_3) break;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":12 */
__pyx_v_i = (__pyx_v_i + 1);
}
__pyx_L6:;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":13 */
__pyx_4 = (__pyx_v_i == __pyx_v_k);
if (__pyx_4) {
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":14 */
(__pyx_v_p[__pyx_v_k]) = __pyx_v_n;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":15 */
__pyx_v_k = (__pyx_v_k + 1);
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":16 */
__pyx_1 = PyObject_GetAttrString(__pyx_v_result, "append"); if (!__pyx_1) goto __pyx_L1;
__pyx_5 = PyInt_FromLong(__pyx_v_n); if (!__pyx_5) goto __pyx_L1;
__pyx_6 = PyTuple_New(1); if (!__pyx_6) goto __pyx_L1;
PyTuple_SET_ITEM(__pyx_6, 0, __pyx_5);
__pyx_5 = 0;
__pyx_5 = PyObject_CallObject(__pyx_1, __pyx_6); if (!__pyx_5) goto __pyx_L1;
Py_DECREF(__pyx_6); __pyx_6 = 0;
Py_DECREF(__pyx_5); __pyx_5 = 0;
goto __pyx_L7;
}
__pyx_L7:;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":17 */
__pyx_v_n = (__pyx_v_n + 1);
}
__pyx_L4:;
/* "ProjectsA:Python:Pyrex:Demos:primes.pyx":18 */
Py_INCREF(__pyx_v_result);
__pyx_r = __pyx_v_result;
goto __pyx_L0;
__pyx_r = Py_None; Py_INCREF(__pyx_r);
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_1);
Py_XDECREF(__pyx_5);
Py_XDECREF(__pyx_6);
__pyx_r = 0;
__pyx_L0:;
Py_DECREF(__pyx_v_result);
return __pyx_r;
}
static struct PyMethodDef __pyx_methods[] = {
{"primes", (PyCFunction)__pyx_f_primes, METH_VARARGS, 0},
{0, 0, 0, 0}
};
void initprimes(void); /*proto*/
void initprimes(void) {
__pyx_m = Py_InitModule4("primes", __pyx_methods, 0, 0, PYTHON_API_VERSION);
__pyx_d = PyModule_GetDict(__pyx_m);
__pyx_b = PyImport_AddModule("__builtin__");
PyDict_SetItemString(__pyx_d, "__builtins__", __pyx_b);
}
/* Runtime support code */
\ No newline at end of file
diff --git a/Doc/sharing.html b/Doc/sharing.html
new file mode 100644
index 00000000..a92856e2
--- /dev/null
+++ b/Doc/sharing.html
@@ -0,0 +1,201 @@
+
+
+
+ Sharing Declarations Between Pyrex Modules
+
+
+
Sharing Declarations Between Pyrex Modules
+
+ This section describes a new set of facilities introduced in Pyrex 0.8
+for making C declarations and extension types in one Pyrex module available
+for use in another Pyrex module. These facilities are closely modelled on
+the Python import mechanism, and can be thought of as a compile-time version
+of it.
+
+ A Pyrex module can be split into two parts: a definition file with
+ a .pxd suffix, containing C declarations that are to be available
+ to other Pyrex modules, and an implementation file with a .pyx
+suffix, containing everything else. When a module wants to use something
+declared in another module's definition file, it imports it using the cimport statement.
+
What a Definition File contains
+ A definition file can contain:
+
+
Any kind of C type declaration.
+
extern C function or variable declarations.
+
The definition part of an extension type (see below).
+
+ It cannot currently contain any non-extern C function or variable declarations
+ (although this may be possible in a future version).
+
It cannot contain the implementations of any C or Python functions, or
+any Python class definitions, or any executable statements.
+
NOTE: You don't need to (and shouldn't) declare anything in a
+declaration file public in order to make it available to other Pyrex
+modules; its mere presence in a definition file does that. You only need a
+public declaration if you want to make something available to external C code.
+
What an Implementation File contains
+ An implementation file can contain any kind of Pyrex statement, although
+ there are some restrictions on the implementation part of an extension type
+if the corresponding definition file also defines that type (see below).
+
+
The cimport statement
+ The cimport statement is used in a definition or implementation
+file to gain access to names declared in another definition file. Its syntax
+exactly parallels that of the normal Python import statement:
+
cimport module [, module...]
+
from module cimport name
+[as name] [, name [as name]
+ ...]
+ Here is an example. The file on the left is a definition file which exports
+ a C data type. The file on the right is an implementation file which imports
+ and uses it.
+
+
+
+
dishes.pxd
+
restaurant.pyx
+
+
+
cdef enum otherstuff:
+ sausage, eggs, lettuce
cdef struct spamdish:
+ int oz_of_spam
+ otherstuff filler
It is important to understand that the cimport statement can only
+be used to import C data types, external C functions and variables, and extension
+types. It cannot be used to import any Python objects, and (with one exception)
+it doesn't imply any Python import at run time. If you want to refer to any
+Python names from a module that you have cimported, you will have to include
+a regular import statement for it as well.
+
The exception is that when you use cimport to import an extension
+ type, its type object is imported at run time and made available by the
+name under which you imported it. Using cimport to import extension
+types is covered in more detail below.
+
+
Search paths for definition files
+ When you cimport a module called modulename, the Pyrex
+compiler searches for a file called modulename.pxd along the search
+path for include files, as specified by -I command line options.
+
Also, whenever you compile a file modulename.pyx, the corresponding
+ definition file modulename.pxd is first searched for along the
+same path, and if found, it is processed before processing the .pyx
+file.
+
Using cimport to resolve naming
+ conflicts
+ The cimport mechanism provides a clean and simple way to solve the problem
+ of wrapping external C functions with Python functions of the same name.
+All you need to do is put the extern C declarations into a .pxd file for
+an imaginary module, and cimport that module. You can then refer to the C
+functions by qualifying them with the name of the module. Here's an example:
+
+
+
+
+
c_lunch.pxd
+
lunch.pyx
+
+
+
cdef extern from "lunch.h":
+
+ void eject_tomato(float)
You don't need any c_lunch.pyx file, because the only things
+defined in c_lunch.pxd are extern C entities. There won't be any
+actual c_lunch module at run time, but that doesn't matter -- c_lunch
+has done its job of providing an additional namespace at compile time.
+
Sharing Extension Types
+ An extension type declaration can also be split into two parts, one in
+a definition file and the other in the corresponding implementation file.
+
+
+ The definition part of the extension type can only declare C attributes
+and C methods, not Python methods, and it must declare all of that
+type's C attributes and C methods.
+
+ The implementation part must implement all of the C methods declared in
+the definition part, and may not add any further C attributes. It may also
+define Python methods.
+
Here is an example of a module which defines and exports an extension
+type, and another module which uses it.
+
+
+
+
Shrubbing.pxd
+
Shrubbing.pyx
+
+
+
cdef class Shrubbery:
+ cdef int width
+ cdef int length
+
cdef class Shrubbery:
+ def __new__(self, int w, int l):
+ self.width = w
+
+ self.length = l
+
cdef Shrubbing.Shrubbery sh
+ sh = Shrubbing.standard_shrubbery()
+ print "Shrubbery size is %d x %d" % (sh.width, sh.height)
+
+
+
+
+
+
+
Some things to note about this example:
+
+
There is a cdef class Shrubbery declaration in both Shrubbing.pxd
+ and Shrubbing.pyx. When the Shrubbing module is compiled, these two declarations
+ are combined into one.
+
+
In Landscaping.pyx, the cimport Shrubbing declaration
+allows us to refer to the Shrubbery type as Shrubbing.Shrubbery.
+But it doesn't bind the name Shrubbery in Landscaping's module namespace
+ at run time, so to access Shrubbery.standard_shrubbery we also
+need to import Shrubbing.
+
+ Back to the Language Overview
+
+
+
\ No newline at end of file
diff --git a/Doc/special_methods.html b/Doc/special_methods.html
new file mode 100644
index 00000000..b5ef495e
--- /dev/null
+++ b/Doc/special_methods.html
@@ -0,0 +1,598 @@
+
+
+
+ Special Methods of Extenstion Types
+
+
Special Methods of Extension Types
+
+ This page describes the special methods currently supported by Pyrex extension
+ types. A complete list of all the special methods appears in the table at
+the bottom. Some of these methods behave differently from their Python counterparts
+or have no direct Python counterparts, and require special mention.
+
Note: Everything said on this page applies only to extension
+types, defined with the cdef class statement. It doesn't apply
+to classes defined with the Python classstatement, where the normal
+ Python rules apply.
+
Declaration
Special methods of extension types must be declared with def, notcdef.
+
Docstrings
+
+ Currently, docstrings are not fully supported in special methods of extension
+ types. You can place a docstring in the source to serve as a comment, but
+ it won't show up in the corresponding __doc__ attribute at run time. (This
+ is a Python limitation -- there's nowhere in the PyTypeObject data structure
+ to put such docstrings.)
+
Initialisation methods: __new__ and __init__
+ There are two methods concerned with initialising the object.
+
The __new__ method is where you should perform basic C-level
+initialisation of the object, including allocation of any C data structures
+that your object will own. You need to be careful what you do in the __new__
+method, because the object may not yet be a valid Python object when it is
+called. Therefore, you must not invoke any Python operations which might touch
+the object; in particular, do not try to call any of its methods.
+
Unlike the corresponding method in Python, your __new__ method
+ is not responsible for creating the object. By the time your
+ __new__ method is called, memory has been allocated for the object
+and any C attributes it has have been initialised to 0 or null. (Any Python
+attributes have also been initialised to None, but you probably shouldn't
+rely on that.) Your __new__ method is guaranteed to be called exactly
+once.
+
+If your extension type has a base type, the __new__ method of the
+base type is automatically called before your __new__ method
+is called; you cannot explicitly call the inherited __new__ method.
+If you need to pass a modified argument list to the base type, you will have
+to do the relevant part of the initialisation in the __init__ method
+instead (where the normal rules for calling inherited methods apply).
+
+
Note that the first parameter of the __new__ method is the object
+to be initialised, not the class of the object as it is in Python.
+
Any initialisation which cannot safely be done in the __new__
+method should be done in the __init__ method. By the time
+ __init__ is called, the object is a fully valid Python object and
+all operations are safe. Under some circumstances it is possible for __init__
+to be called more than once or not to be called at all, so your other methods
+ should be designed to be robust in such situations.
+
Keep in mind that any arguments passed to the constructor will be passed
+ to the __new__ method as well as the __init__ method.
+If you anticipate subclassing your extension type in Python, you may find
+it useful to give the __new__ method * and ** arguments so that
+it can accept and ignore extra arguments. Otherwise, any Python subclass
+which has an __init__ with a different signature will have to override
+__new__ as well as __init__, which the writer of a Python
+class wouldn't expect to have to do.
+
Finalization method: __dealloc__
+ The counterpart to the __new__ method is the __dealloc__
+method, which should perform the inverse of the __new__ method.
+Any C data structures that you allocated in your __new__ method
+should be freed in your __dealloc__ method.
+
You need to be careful what you do in a __dealloc__ method. By
+the time your __dealloc__ method is called, the object may already
+have been partially destroyed and may not be in a valid state as far as Python
+is concerned, so you should avoid invoking any Python operations which might
+touch the object. In particular, don't call any other methods of the object
+or do anything which might cause the object to be resurrected. It's best if
+you stick to just deallocating C data.
+
You don't need to worry about deallocating Python attributes of your object,
+because that will be done for you by Pyrex after your __dealloc__
+method returns.
+
+ Note: There is no __del__ method for extension types. (Earlier
+versions of the Pyrex documentation stated that there was, but this turned
+out to be incorrect.)
+
+
Arithmetic methods
+ Arithmetic operator methods, such as __add__, behave differently
+ from their Python counterparts. There are no separate "reversed" versions
+ of these methods (__radd__, etc.) Instead, if the first operand
+cannot perform the operation, the same method of the second operand
+is called, with the operands in the same order.
+
This means that you can't rely on the first parameter of these methods
+ being "self", and you should test the types of both operands before deciding
+ what to do. If you can't handle the combination of types you've been given,
+ you should return NotImplemented.
+
This also applies to the in-place arithmetic method __ipow__.
+ It doesn't apply to any of the other in-place methods (__iadd__,
+ etc.) which always take self as the first argument.
+
Rich comparisons
+ There are no separate methods for the individual rich comparison operations
+ (__eq__, __le__, etc.) Instead there is a single method
+ __richcmp__ which takes an integer indicating which operation is
+to be performed, as follows:
+
+
+
+
+
+
<
+
+
0
+
+
+
==
+
+
2
+
+
+
>
+
+
4
+
+
+
<=
+
+
1
+
+
+
!=
+
+
3
+
+
+
>=
+
+
5
+
+
+
+
+
The __next__ method
+ Extension types wishing to implement the iterator interface should define
+ a method called __next__, notnext. The Python
+ system will automatically supply a next method which calls your
+__next__. Do NOT explicitly give your type a next method,
+or bad things could happen (see note 3).
+
Special Method Table
+ This table lists all of the special methods together with their parameter
+ and return types. A parameter named self is of the type the method
+ belongs to. Other untyped parameters are generic Python objects.
+
You don't have to declare your method as taking these parameter types.
+ If you declare different types, conversions will be performed as necessary.
+
+
+
+
+
Name
+
Parameters
+
Return type
+
Description
+
+
+
General
+
+
+
__new__
+
self, ...
+
+
Basic initialisation (no direct Python equivalent)
+
+
+
__init__
+
self, ...
+
+
Further initialisation
+
+
+
__dealloc__
+
self
+
+
Basic deallocation (no direct Python equivalent)
+
+
+
__cmp__
+
x, y
+
int
+
3-way comparison
+
+
+
__richcmp__
+
x, y, int op
+
object
+
Rich comparison (no direct Python equivalent)
+
+
+
__str__
+
self
+
object
+
str(self)
+
+
+
__repr__
+
self
+
object
+
repr(self)
+
+
+
__hash__
+
self
+
int
+
Hash function
+
+
+
__call__
+
self, ...
+
object
+
self(...)
+
+
+
__iter__
+
self
+
object
+
Return iterator for sequence
+
+
+
__getattr__
+
self, name
+
object
+
Get attribute
+
+
+
__setattr__
+
self, name, val
+
+
Set attribute
+
+
+
__delattr__
+
self, name
+
+
Delete attribute
+
+
+
Arithmetic operators
+
+
+
__add__
+
x, y
+
object
+
binary + operator
+
+
+
__sub__
+
x, y
+
object
+
binary - operator
+
+
+
__mul__
+
x, y
+
object
+
* operator
+
+
+
__div__
+
x, y
+
object
+
/ operator for old-style division
+
+
+
__floordiv__
+
x, y
+
object
+
// operator
+
+
+
__truediv__
+
x, y
+
object
+
/ operator for new-style division
+
+
+
__mod__
+
x, y
+
object
+
% operator
+
+
+
__divmod__
+
x, y
+
object
+
combined div and mod
+
+
+
__pow__
+
x, y, z
+
object
+
** operator or pow(x, y, z)
+
+
+
__neg__
+
self
+
object
+
unary - operator
+
+
+
__pos__
+
self
+
object
+
unary + operator
+
+
+
__abs__
+
self
+
object
+
absolute value
+
+
+
__nonzero__
+
self
+
int
+
convert to boolean
+
+
+
__invert__
+
self
+
object
+
~ operator
+
+
+
__lshift__
+
x, y
+
object
+
<< operator
+
+
+
__rshift__
+
x, y
+
object
+
>> operator
+
+
+
__and__
+
x, y
+
object
+
& operator
+
+
+
__or__
+
x, y
+
object
+
| operator
+
+
+
__xor__
+
x, y
+
object
+
^ operator
+
+
+
Numeric conversions
+
+
+
__int__
+
self
+
object
+
Convert to integer
+
+
+
__long__
+
self
+
object
+
Convert to long integer
+
+
+
__float__
+
self
+
object
+
Convert to float
+
+
+
__oct__
+
self
+
object
+
Convert to octal
+
+
+
__hex__
+
self
+
object
+
Convert to hexadecimal
+
+
+
In-place arithmetic operators
+
+
+
__iadd__
+
self, x
+
object
+
+= operator
+
+
+
__isub__
+
self, x
+
object
+
-= operator
+
+
+
__imul__
+
self, x
+
object
+
*= operator
+
+
+
__idiv__
+
self, x
+
object
+
/= operator for old-style division
+
+
+
__ifloordiv__
+
self, x
+
object
+
//= operator
+
+
+
__itruediv__
+
self, x
+
object
+
/= operator for new-style division
+
+
+
__imod__
+
self, x
+
object
+
%= operator
+
+
+
__ipow__
+
x, y, z
+
object
+
**= operator
+
+
+
__ilshift__
+
self, x
+
object
+
<<= operator
+
+
+
__irshift__
+
self, x
+
object
+
>>= operator
+
+
+
__iand__
+
self, x
+
object
+
&= operator
+
+
+
__ior__
+
self, x
+
object
+
|= operator
+
+
+
__ixor__
+
self, x
+
object
+
^= operator
+
+
+
Sequences and mappings
+
+
+
__len__
+
self
+
int
+
len(self)
+
+
+
__getitem__
+
self, x
+
object
+
self[x]
+
+
+
__setitem__
+
self, x, y
+
+
self[x] = y
+
+
+
__delitem__
+
self, x
+
+
del self[x]
+
+
+
__getslice__
+
self, int i, int j
+
object
+
self[i:j]
+
+
+
__setslice__
+
self, int i, int j, x
+
+
self[i:j] = x
+
+
+
__delslice__
+
self, int i, int j
+
+
del self[i:j]
+
+
+
__contains__
+
self, x
+
int
+
x in self
+
+
+
Iterators
+
+
+
__next__
+
self
+
object
+
Get next item (called next in Python)
+
+
+
Buffer interface (no Python equivalents
+ - see note 1)
+
+
+
__getreadbuffer__
+
self, int i, void **p
+
+
+
+
+
__getwritebuffer__
+
self, int i, void **p
+
+
+
+
+
__getsegcount__
+
self, int *p
+
+
+
+
+
__getcharbuffer__
+
self, int i, char **p
+
+
+
+
+
Descriptor objects (no Python equivalents
+ - see note 2)
+
+
+
__get__
+
self, instance, class
+
object
+
Get value of attribute
+
+
+
__set__
+
self, instance, value
+
+
Set value of attribute
+
+
+
__delete__
+
self, instance
+
+
Delete attribute
+
+
+
+
Note 1: The buffer interface is intended for use by C code and is not
+directly accessible from Python. It is described in the Python/C API Reference
+Manual under sections 6.6
+and 10.6.
+
Note 3: If your type defines a __new__ method, any method called
+ new that you define will be overwritten with the system-supplied
+ new at module import time.
+
+
+
\ No newline at end of file
diff --git a/INSTALL.txt b/INSTALL.txt
new file mode 100644
index 00000000..3dccaa67
--- /dev/null
+++ b/INSTALL.txt
@@ -0,0 +1,22 @@
+Pyrex - Installation Instructions
+=================================
+
+You have two installation options:
+
+(1) Run the setup.py script in this directory
+ as follows:
+
+ python setup.py install
+
+ This will install the Pyrex package
+ into your Python system.
+
+OR
+
+(2) If you prefer not to modify your Python
+ installation, arrange for the directory
+ containing this file (INSTALL.txt) to be in
+ your PYTHONPATH. On unix, also put the bin
+ directory on your PATH.
+
+See README.txt for pointers to other documentation.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 00000000..5615d2fb
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,50 @@
+The PYTHON SOFTWARE FOUNDATION LICENSE:
+
+PSF LICENSE AGREEMENT FOR PYTHON 2.4
+------------------------------------
+
+1. This LICENSE AGREEMENT is between the Python Software Foundation
+("PSF"), and the Individual or Organization ("Licensee") accessing and
+otherwise using Python 2.4 software in source or binary form and its
+associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, PSF
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
+license to reproduce, analyze, test, perform and/or display publicly,
+prepare derivative works, distribute, and otherwise use Python 2.4
+alone or in any derivative version, provided, however, that PSF's
+License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
+2001, 2002, 2003, 2004 Python Software Foundation; All Rights Reserved"
+are retained in Python 2.4 alone or in any derivative version prepared
+by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates Python 2.4 or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to Python 2.4.
+
+4. PSF is making Python 2.4 available to Licensee on an "AS IS"
+basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.4 WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+2.4 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.4,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between PSF and
+Licensee. This License Agreement does not grant permission to use PSF
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using Python 2.4, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 00000000..7710f3e0
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,7 @@
+include MANIFEST.in README.txt INSTALL.txt CHANGES.txt ToDo.txt USAGE.txt
+include setup.py
+include bin/pyrexc
+include pyrexc.py
+include Pyrex/Compiler/Lexicon.pickle
+include Doc/*
+include Demos/*
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..099ccfb8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,18 @@
+VERSION = 0.9.4.1
+
+version:
+ @echo "Setting version to $(VERSION)"
+ @echo "version = '$(VERSION)'" > Pyrex/Compiler/Version.py
+
+#check_contents:
+# @if [ ! -d Pyrex/Distutils ]; then \
+# echo Pyrex/Distutils missing; \
+# exit 1; \
+# fi
+
+clean:
+ @echo Cleaning Source
+ @rm -f *.pyc */*.pyc */*/*.pyc
+ @rm -f *~ */*~ */*/*~
+ @rm -f core */core
+ @(cd Demos; $(MAKE) clean)
diff --git a/README.txt b/README.txt
new file mode 100644
index 00000000..4a70f7c2
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,58 @@
+Welcome to Cython!
+=================
+
+Cython (http://www.cython.org) is based on Pyrex, but
+supports more cutting edge functionality and optimizations.
+
+LICENSE:
+
+The original Pyrex program was licensed "free of restrictions" (see
+below). Cython itself is licensed under the
+
+ PYTHON SOFTWARE FOUNDATION LICENSE
+ http://www.python.org/psf/license/
+
+
+
+
+
+--------------------------
+
+To see the change history, go to the Pyrex directory and type
+
+ $ hg log
+
+This requires that you have installed Mercurial.
+
+ -- William Stein (wstein@gmail.com)
+
+xxxx
+
+
+The following is from Pyrex:
+------------------------------------------------------
+This is a development version of Pyrex, a language
+for writing Python extension modules.
+
+For more info, see:
+
+ Doc/About.html for a description of the language
+ INSTALL.txt for installation instructions
+ USAGE.txt for usage instructions
+ Demos for usage examples
+
+Comments, suggestions, bug reports, etc. are
+welcome!
+
+Copyright stuff: Pyrex is free of restrictions. You
+may use, redistribute, modify and distribute modified
+versions.
+
+The latest version of Pyrex can be found here:
+
+http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
+
+Greg Ewing, Computer Science Dept, +--------------------------------------+
+University of Canterbury, | A citizen of NewZealandCorp, a |
+Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
+greg@cosc.canterbury.ac.nz +--------------------------------------+
diff --git a/ToDo.txt b/ToDo.txt
new file mode 100644
index 00000000..5b5701b9
--- /dev/null
+++ b/ToDo.txt
@@ -0,0 +1,284 @@
+DONE - Pointer-to-function types.
+
+DONE - Nested declarators.
+
+DONE - Varargs C func defs and calls.
+
+DONE - * and ** args in Python func defs.
+
+DONE - Default argument values.
+
+DONE - Tracebacks.
+
+DONE - Disallow creating char * from Python temporary anywhere
+ (not just on assignment).
+
+DONE - Module and function and class doc strings.
+
+DONE - Predeclare C functions.
+
+DONE - Constant expressions.
+
+DONE - Forward C struct declarations.
+
+DONE - Prefix & operator.
+
+DONE - Get rid of auto string->char coercion and
+ add a c'X' syntax for char literals.
+
+DONE - Cascaded assignments (a = b = c).
+
+DONE - 'include' statement for including other Pyrex files.
+
+DONE - Add command line option for specifying name of generated C file.
+
+DONE - Add 'else' clause to try-except.
+
+DONE - Allow extension types to be declared "public" so they
+ can be accessed from another Pyrex module or a C file.
+
+DONE - Don't try to generate objstruct definition for external
+ extension type declared without suite (treat as though
+ declared with empty suite).
+
+DONE - Implement two-argument form of 'assert' statement.
+
+Const types.
+
+Tuple/list construction: Evaluate & store items one at a time?
+
+Varargs argument traversal.
+
+Use PyDict_SetItemString to build keyword arg dicts?
+(Or wait until names are interned.)
+
+Intern names.
+
+print >>file
+
+abs() and anything similar.
+
+Semicolon-separated statement lists.
+
+Optional semicolons after C declarations.
+
+Multiple C declarations on one line?
+
+Optimise return without value outside of try-finally.
+
+exec statement.
+
+from ... import statement.
+
+Use iterator protocol for unpacking.
+
+Save & restore exception being handled on function entry/exit.
+
+In-place operators (+=, etc).
+
+Constant declarations. Syntax?
+
+DONE - Some way for C functions to signal Python errors?
+
+Check for lack of return with value in non-void C functions?
+
+Allow 'pass' in struct/union/enum definition.
+
+Make C structs callable as constructors.
+
+DONE - Provide way of specifying C names.
+
+DONE - Public cdefs.
+
+When calling user __dealloc__ func, save & restore exception.
+
+DONE - Forward declaration of extension types.
+
+Complex number parsetuple format?
+
+DONE - long long type
+
+DONE - long double type?
+
+Windows __fooblarg function declaration things.
+
+Generate type, var and func declarations in the same order that
+they appear in the source file.
+
+Provide a way of declaring a C function as returning a
+borrowed Python reference.
+
+Provide a way of specifying whether a Python object obtained
+by casting a pointer should be treated as a new reference
+or not.
+
+Optimize integer for-loops.
+
+Make sizeof() take types as well as variables.
+
+Allow "unsigned" to be used alone as a type name.
+
+Allow duplicate declarations, at least in extern-from.
+
+Do something about installing proper version of pyrexc
+script according to platform in setup.py.
+
+DONE - Add "-o filename" command line option to unix/dos versions.
+
+Recognise #line directives?
+
+Catch floating point exceptions?
+
+Check that forward-declared non-external extension types
+are defined.
+
+Generate type test when casting from one Python type
+to another.
+
+Generate a Pyrex include file for public declarations
+as well as a C one.
+
+Syntax for defining indefinite-sized int & float types.
+
+Allow ranges of exception values.
+
+Support "complex double" and "complex float"?
+
+Allow module-level Python variables to be declared extern.
+
+Consider:
+>cdef extern from "foo.h":
+> int dosomething() except -1 raise MyException
+
+Properties for Python types.
+
+DONE - Properties for extension types.
+
+Find a way to make classmethod and staticmethod work better.
+
+DONE - Document workarounds for classmethod and staticmethod.
+
+Statically initialised C arrays & structs.
+
+Reduce generation of unused vars and unreachable code?
+
+Support for acquiring and releasing GIL.
+
+Make docstrings of extension type special methods work.
+
+Treat result of getting C attribute of extension type as non-ephemeral.
+
+Make None a reserved identifier.
+
+Teach it about builtin functions that correspond to
+Python/C API calls.
+
+Teach it about common builtin types.
+
+Option for generating a main() function?
+
+DONE - Allow an extension type to inherit from another type.
+
+Do something about external C functions declared as returning
+const * types?
+
+Use PyString_FromStringAndSize for string literals?
+
+DONE - C functions as methods of extension types.
+
+What to do about __name__ etc. attributes of a module (they are
+currently assumed to be built-in names).
+
+Use PyDict_GetItem etc. on module & builtins dicts for speed.
+
+Intern all string literals used as Python strings?
+[Koshy ]
+
+Make extension types weak-referenceable.
+[Matthias Baas ]
+
+Make 'pass' work in the body of an extern-from struct
+or union.
+
+Disallow a filename which results in an illegal identifier when
+used as a module name.
+
+Use ctypedef names.
+
+Provide an easy way of exposing a set of enum values as Python names.
+[John J Lee ]
+
+Prevent user from returning a value from special methods that
+return an error indicator only.
+
+Use PyObject_TypeCheck instead of PyObject_IsInstance?
+
+Allow * in cimport? [John J Lee ]
+
+FAQ: Q. Pyrex says my extension type object has no attribute 'rhubarb', but
+ I know it does.
+
+ A. Have you declared the type at the point where you're using it?
+
+Eliminate lvalue casts! (Illegal in C++, also disallowed by some C compilers)
+[Matthias Baas ]
+
+Make Python class construction work more like it does in Python.
+
+Give the right module name to Python classes.
+
+Command line switch for full pathnames in backtraces?
+
+Use PyString_FromStringAndSize on string literals containing
+nulls.
+
+Peephole optimisation? [Vladislav Bulatov ]
+
+Avoid PyArg_ParseTuple call when a function takes no positional args.
+
+Omit incref/decref of arguments that are not assigned to?
+
+Can a faster way of instantiating extension types be found?
+
+Disallow declaring a special method of an extension type with
+'cdef' instead of 'def'.
+
+Use PySequence_GetItem instead of PyObject_GetItem when index
+is an integer.
+
+If a __getitem__ method is declared with an int index, use the
+sq_item slot instead of the mp_subscript slot.
+
+Provide some way of controlling the argument list passed to
+an extension type's base __new__ method?
+[Alain Pointdexter ]
+
+Rename __new__ in extension types to __alloc__.
+
+Implement a true __new__ for extension types.
+
+Way to provide constructors for extension types that are not
+available to Python and can accept C types directly?
+
+Support generators by turning them into extension types?
+
+List comprehensions.
+
+Variable declarations inside inner code blocks?
+
+Initial values when declaring variables?
+
+Do something about __stdcall.
+
+Support class methods in extension types using METH_CLASS flag.
+
+Disallow defaulting types to 'object' in C declarations?
+
+C globals with static initialisers.
+
+Find a way of providing C-only initialisers for extension types.
+
+Metaclasses for extension types?
+
+Make extension types use Py_TPFLAGS_HEAPTYPE so their __module__
+will get set dynamically?
diff --git a/Tools/pyrex-mode.el b/Tools/pyrex-mode.el
new file mode 100644
index 00000000..1493a9d8
--- /dev/null
+++ b/Tools/pyrex-mode.el
@@ -0,0 +1 @@
+;;;; `Pyrex' mode.
(add-to-list 'auto-mode-alist '("\\.pyx\\'" . pyrex-mode))
(define-derived-mode pyrex-mode python-mode "Pyrex"
(font-lock-add-keywords
nil
`((,(concat "\\<\\(NULL"
"\\|c\\(def\\|har\\|typedef\\)"
"\\|e\\(num\\|xtern\\)"
"\\|float"
"\\|in\\(clude\\|t\\)"
"\\|object\\|public\\|struct\\|type\\|union\\|void"
"\\)\\>")
1 font-lock-keyword-face t))))
\ No newline at end of file
diff --git a/Tools/pyrex.st b/Tools/pyrex.st
new file mode 100644
index 00000000..d4fe4ecf
--- /dev/null
+++ b/Tools/pyrex.st
@@ -0,0 +1 @@
+/**
* Name: pyrex
* Description: Pyrex - a Language for Writing Python Extension Modules
* Author: Markku Rossi
*/
state pyrex extends python
{
/* Additional keywords.
(build-re '( NULL as cdef char ctypedef double enum extern float
include int long private public short signed sizeof struct union
unsigned void )) */
/\b(NULL|as|c(def|har|typedef)|double|e(num|xtern)|float|in(clude|t)\
|long|p(rivate|ublic)|s(hort|i(gned|zeof)|truct)|un(ion|signed)|void)\b/ {
keyword_face(true);
language_print($0);
keyword_face(false);
}
}
/*
Local variables:
mode: c
End:
*/
\ No newline at end of file
diff --git a/USAGE.txt b/USAGE.txt
new file mode 100644
index 00000000..3128cd01
--- /dev/null
+++ b/USAGE.txt
@@ -0,0 +1,69 @@
+Pyrex - Usage Instructions
+==========================
+
+Building Pyrex extensions using distutils
+-----------------------------------------
+
+Pyrex comes with an experimental distutils extension for compiling
+Pyrex modules, contributed by Graham Fawcett of the University of
+Windsor (fawcett@uwindsor.ca).
+
+The Demos directory contains a setup.py file demonstrating its use. To
+compile the demos:
+
+(1) cd Demos
+
+(2) python setup.py build_ext --inplace
+
+ or
+
+ python setup.py build --build-lib=.
+
+(You may get a screed of warnings from the C compiler, but you can
+ignore these -- as long as there are no actual errors, things are
+probably okay.)
+
+Try out the extensions with:
+
+ python run_primes.py
+ python run_spam.py
+ python run_numeric_demo.py
+
+
+Building Pyrex extensions by hand
+---------------------------------
+
+You can also invoke the Pyrex compiler on its own to translate a .pyx
+file to a .c file. On Unix,
+
+ pyrexc filename.pyx
+
+On other platforms,
+
+ python pyrexc.py filename.pyx
+
+It's then up to you to compile and link the .c file using whatever
+procedure is appropriate for your platform. The file
+Makefile.nodistutils in the Demos directory shows how to do this for
+one particular Unix system.
+
+
+Command line options
+--------------------
+
+The pyrexc command supports the following options:
+
+ Short Long Argument Description
+ -----------------------------------------------------------------------------
+ -v --version Display version number of pyrex compiler
+ -l --create-listing Write error messages to a .lis file
+ -I --include-dir Search for include files in named
+ directory (may be repeated)
+ -o --output-file Specify name of generated C file (only
+ one source file allowed if this is used)
+
+Anything else is taken as the name of a Pyrex source file and compiled
+to a C source file. Multiple Pyrex source files can be specified
+(unless -o is used), in which case each source file is treated as the
+source of a distinct extension module and compiled separately to
+produce its own C file.
diff --git a/bin/cython b/bin/cython
new file mode 100644
index 00000000..b604d4d0
--- /dev/null
+++ b/bin/cython
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+#
+# Pyrex -- Main Program, Unix
+#
+
+from Pyrex.Compiler.Main import main
+main(command_line = 1)
diff --git a/bin/update_references b/bin/update_references
new file mode 100644
index 00000000..70277781
--- /dev/null
+++ b/bin/update_references
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+#
+# Go through the Tests directory and its subdirectories
+# copying the latest versions of the test outputs into
+# the Reference directories.
+#
+
+import os, sys
+
+ignore_names = [".DS_Store", "Icon\r"]
+
+def copy_file(from_path, to_path):
+ # We copy the contents from one file to the other
+ # so as to preserve metadata on the Mac.
+ #print from_path, "-->", to_path
+ f = open(from_path)
+ g = open(to_path, "w+")
+ g.write(f.read())
+ f.close()
+ g.close()
+
+def update_references(out_dir, ref_dir):
+ for name in os.listdir(ref_dir):
+ if name not in ignore_names:
+ out_file = os.path.join(out_dir, name)
+ ref_file = os.path.join(ref_dir, name)
+ if os.path.isfile(out_file):
+ print "Updating", name
+ copy_file(out_file, ref_file)
+
+def update_references_in_dir(dir):
+ print "Updating references in", dir
+ for name in os.listdir(dir):
+ if name <> "Reference" and not name.startswith("("):
+ item_path = os.path.join(dir, name)
+ if os.path.isdir(item_path):
+ update_references_in_dir(item_path)
+ ref_dir = os.path.join(dir, "Reference")
+ if os.path.isdir(ref_dir):
+ update_references(dir, ref_dir)
+
+def main():
+ bin_dir = os.path.dirname(sys.argv[0])
+ source_dir = os.path.dirname(bin_dir)
+ tests_dir = os.path.join(source_dir, "Tests")
+ update_references_in_dir(tests_dir)
+
+if __name__ == "__main__":
+ main()
diff --git a/cython.py b/cython.py
new file mode 100644
index 00000000..f32cf153
--- /dev/null
+++ b/cython.py
@@ -0,0 +1,6 @@
+#
+# Pyrex -- Main Program, generic
+#
+
+from Pyrex.Compiler.Main import main
+main(command_line = 1)
diff --git a/setup.py b/setup.py
new file mode 100644
index 00000000..cd1945a1
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,31 @@
+from distutils.core import setup
+from distutils.sysconfig import get_python_lib
+import os
+from Cython.Compiler.Version import version
+
+compiler_dir = os.path.join(get_python_lib(prefix=''), 'Cython/Compiler')
+
+if os.name == "posix":
+ scripts = ["bin/cython"]
+else:
+ scripts = ["cython.py"]
+
+setup(
+ name = 'Cython',
+ version = version,
+ url = 'http://www.cython.org',
+ author = 'Greg Ewing, William Stein, Robert Bradshaw, Stefan Behnel, et al.',
+ author_email = 'wstein@gmail.com',
+ scripts = scripts,
+ packages=[
+ 'Cython',
+ 'Cython.Compiler',
+ 'Cython.Distutils',
+ 'Cython.Mac',
+ 'Cython.Plex'
+ ],
+ data_files=[
+ (compiler_dir, ['Cython/Compiler/Lexicon.pickle'])
+ ]
+ )
+
--
2.26.2