[Dune] [#661] Use Python to evaluate function strings
flyspray at dune-project.org
Wed Mar 14 21:28:45 CET 2012
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
The following task has a new comment added:
FS#661 - Use Python to evaluate function strings
User who did this - Sven Marnach (sven)
1. The main purpose of this feature seems to be rapid prototyping, e.g. the ability to experiment with parameter functions without recompiling, right? If so, it does not matter too much which version of Python is available on HPC systems, since the feature is not meant to be used in production runs anyway.
2. The differences between Python 2 and 3 are shallow. Even complex projects like NumPy manage to support both versions within the same code base. Most people will stay with Python 2 for at least another year or so due to lack of third-part library support (and most third-party libraries won't be ported because nobody is using Python 3 ...).
3. I don't think any Python support should go into dune-common. It seems more useful to decouple the release cycles from the core modules.
4. The main problem I see with Carsten's header file is that it does not do Python error checking. Almost all errors are silently ignored, which can make debugging hard. Apart from this, I think the code is fine for the purpose it is intended for. (The reference counting bug Martin mentioned, while indeed being a bug, has little real-world impact, and apart from this I could find only minor issues I'll report to Carsten by private mail.)
5. I implemented a small header-only library to wrap a DUNE application for Python to be able to do all the high-level stuff in Python. There is a lot of overlap between that library and Carsten's header file. The main feature Carsten's code offers over mine is documentation. The main features my code offers over Carsten's is automatic translation between Python and C++ exceptions, so errors won't pass unnoticed. Though not useful in its current form, I think the error checking makes my code worth mentioning in this thread. Here it is: https://github.com/smarnach/capy
6. Another approach to get Python parameter functions that might be conceptually interesting is to use the 'codegen' module from SymPy (http://docs.sympy.org/0.7.1/modules/utilities/codegen.html). This allows to compile Python functions to a shared library that can be dlopen()ed by the DUNE application. You wouldn't need to embed Python, and the functions would run comparatively fast. Unfortunately, codegen is rather limited -- in particular, it is rather hard to get flow control in your functions, since 'sympy.Piecewise' isn't translated correctly by codegen. It wouldn't be too hard to code up a more useful version of something like this oneself, though.
(Sorry, this comment got too long.)
More information can be found at the following URL:
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
More information about the Dune