[ this page is under construction ]

Introduction

This page describes some techniques for writing really fast Pyrex code. It is aimed at SAGE developers who are working on low-level SAGE internals, where performance is absolutely crucial.

Pyrex is a very unusual language. If you write Pyrex as if it were Python, it can end up running as slowly as Python. If you write it like you're writing C, it can run almost as fast as pure C. The amazing thing about Pyrex is that the programmer gets to choose, pretty much line by line, where along the Python-C spectrum they want to work.

HOWEVER... it is hard work to make your Pyrex as fast as C. It's very easy to get it wrong, essentially because Pyrex makes it all look so easy. This purpose of this document is to collect together the experiences of SAGE developers who have learned the hard way.

How to contribute to this document

Yes, please do! Make sure to follow these guidelines:

Examples

cdef functions vs def functions

[ todo ]

python attributes vs cdef attributes

[ todo ]

avoid python name lookups

[ todo ]

type checking

[ todo ]

"==" vs "is"

[ todo ]