Created
February 23, 2009 22:35
-
-
Save idan/69233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Python/Python.h> | |
int main(int argc, char *argv[]) | |
{ | |
PyObject *psrcstring, *pwriter_name_string, *pmodule, *pmethod, *presult; | |
PyTupleObject *pmethodargs; | |
PyDictObject *pmethodnamedargs; | |
char *output; | |
char *source = "Djoosh \n======\n\n`Djoosh`_ is a reusable django app which provides extensible, pure-python fulltext indexing for Django models using the `Whoosh`_ information-retrieval library. \n\nThe djoosh project lives at http://github.com/idangazit/djoosh/.\n\n.. _Djoosh: http://github.com/idangazit/djoosh/\n\n\nProject Goals\n-------------\n\nDjoosh will:\n \n * be a **pure-python** fulltext indexing solution. There are many fine solutions based around `Lucene`_ and `Solr`_ (java), or `Xapian`_ (C/C++). There is even one solution (`django-search`_) which provides pluggable indexing backends much like the ORM supports various DB backends. This project utilizes `Whoosh`_ exclusively.\n * be simple enough to make \"**out of the box indexing**\" no harder than registering a model for usage in django\'s admin.\n * be **flexible/extensible** enough that you can specify custom indexing behavior for a model if you need it -- much like you can specify a custom form for the admin.\n * be as **pythonic, djangonic and KISS** as we can make it. :)\n \n .. _Whoosh: http://trac.whoosh.ca/\n .. _Lucene: http://lucene.apache.org/java/docs/\n .. _Solr: http://lucene.apache.org/solr/\n .. _Xapian: http://xapian.org/\n .. _django-search: http://code.google.com/p/djangosearch/\n"; | |
int i=0; | |
for (i=0; i<500; i++) { | |
printf("Starting round %i...\n", i); | |
Py_Initialize(); | |
pmethodargs = PyTuple_New(1); | |
pmethodnamedargs = PyDict_New(); | |
psrcstring = PyString_FromString(source); | |
PyTuple_SetItem(pmethodargs, 0, psrcstring); | |
pwriter_name_string = PyString_FromString("html"); | |
PyDict_SetItemString(pmethodnamedargs, "writer_name", pwriter_name_string); | |
pmodule = PyImport_ImportModule("docutils.core"); | |
pmethod = PyObject_GetAttrString(pmodule, "publish_string"); | |
presult = PyObject_Call(pmethod, pmethodargs, pmethodnamedargs); | |
PyArg_Parse(presult, "s", &output); | |
Py_DECREF(presult); | |
Py_DECREF(pmethod); | |
Py_DECREF(pmodule); | |
Py_DECREF(pwriter_name_string); | |
Py_DECREF(psrcstring); | |
Py_DECREF(pmethodnamedargs); | |
Py_DECREF(pmethodargs); | |
Py_Finalize(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment