SciPy 0.6.0 API Documentation Generated by Endo, 2007-10-17
Track relationships between compiled extension functions & code fragments
catalog keeps track of which compiled(or even standard) functions are related to which code fragments. It also stores these relationships to disk so they are remembered between Python sessions. When
a = 1 compiler.inline('printf("printed from C: %d",a);',['a'] )
is called, inline() first looks to see if it has seen the code 'printf("printed from C");' before. If not, it calls
catalog.get_functions('printf("printed from C: %d", a);')
which returns a list of all the function objects that have been compiled for the code fragment. Multiple functions can occur because the code could be compiled for different types for 'a' (although not likely in this case). The catalog first looks in its cache and quickly returns a list of the functions if possible. If the cache lookup fails, it then looks through possibly multiple catalog files on disk and fills its cache with all the functions that match the code fragment.
In case where the code fragment hasn't been compiled, inline() compiles the code and then adds it to the catalog:
function = <code to compile function> catalog.add_function('printf("printed from C: %d", a);',function)
add_function() adds function to the front of the cache. function, along with the path information to its module, are also stored in a persistent catalog for future use by python sessions.
Return the full path name for the catalog file in the given directory.
module_path can either be a file name or a path name. If it is a file name, the catalog file name in its parent directory is returned. If it is a directory, the catalog file in that directory is returned.
If module_path doesn't exist, None is returned. Note though, that the catalog file does not have to exist, only its parent. '~', shell variables, and relative ('.' and '..') paths are all acceptable.
catalog file names are os dependent (based on sys.platform), so this should support multiple platforms sharing the same disk space (NFS mounts). See os_dependent_catalog_name() for more info.
Create a directory and any necessary intermediate directories.
Return a default location to store compiled files and catalogs.
XX is the Python version number in all paths listed below On windows, the default location is the temporary directory returned by gettempdir()/pythonXX.
On Unix, ~/.pythonXX_compiled is the default location. If it doesn't exist, it is created. The directory is marked rwx------.
If for some reason it isn't possible to build a default directory in the user's home, /tmp/<uid>_pythonXX_compiled is used. If it doesn't exist, it is created. The directory is marked rwx------ to try and keep people from being able to sneak a bad module in on you.
Convert an arbitrary expr string to a valid file name.
The name is based on the md5 check sum for the string and Something that was a little more human readable would be nice, but the computer doesn't seem to care.
Return a function catalog (shelve object) from the path module_path
If module_path is a directory, the function catalog returned is from that directory. If module_path is an actual module_name, then the function catalog returned is from its parent directory. mode uses the standard 'c' = create, 'n' = new, 'r' = read, 'w' = write file open modes available for anydbm databases.
Well... it should be. Stuck with dumbdbm for now and the modes almost don't matter. We do some checking for 'r' mode, but that is about it.
See catalog_path() for more information on module_path.
Discover the name of the module where object was defined.
This is an augmented version of inspect.getmodule that can discover the parent module for extension functions.
Location in temp dir for storing .cpp and .o files during builds.
Determine whether a given directory is writable in a portable manner.
| Parameters: |
|
|---|---|
| Returns: | True or False. |
Generate catalog name dependent on OS and Python version being used.
This allows multiple platforms to have catalog files in the same directory without stepping on each other. For now, it bases the name of the value returned by sys.platform and the version of python being run. If this isn't enough to descriminate on some platforms, we can try to add other info. It has occured to me that if we get fancy enough to optimize for different architectures, then chip type might be added to the catalog name also.
Generate a unqiue file name based on expr in directory d
This is meant for use with building extension modules, so a file name is considered unique if none of the following extension '.cpp','.o','.so','module.so','.py', or '.pyd' exists in directory d. The fully qualified path to the new name is returned. You'll need to append your own extension to it before creating files.
return a string identifying the user.
| Local name | Refers to |
|---|---|
| os | os |
| pickle | pickle |
| socket | socket |
| string | string |
| sys | sys |
| tempfile | tempfile |