Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71767
| Date | 2014-05-19 18:37 +0200 |
|---|---|
| From | Roland Plüss <roland@rptd.ch> |
| Subject | Re: Loading modules from files through C++ |
| References | (7 earlier) <ll80dl$bov$1@ger.gmane.org> <53778E22.3040701@rptd.ch> <ll84s5$5bd$1@ger.gmane.org> <53790CCF.1070905@rptd.ch> <CAPTjJmrOeSsmoxqk8iCL2tKEX9Qa1yHBLzfbfvNr_7Ap+AP6pg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10139.1400517468.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On 05/19/2014 03:40 AM, Chris Angelico wrote: > On Mon, May 19, 2014 at 5:41 AM, Roland Plüss <roland@rptd.ch> wrote: >> This exec source_code in module.__dict__ , should this not also be doable >> with PyEval_EvalCode? > General principle: The more code you write in Python and the less in > C/C++, the happier and more productive you will be. > > Drop into Python as soon as you can, and do all the work from there. > You won't have to worry about RAM (de)allocation, Unicode (especially > if you use Python 3 rather than 2), integer overflow, etc, etc, etc. > Only write lower-level code for the bits that actually demand it; and > as Stefan has pointed out, Cython is a great help there. > > (Which reminds me. I still need some "excuse project" to justify my > learning Cython. It's good-looking tech but everything I can imagine > writing seems to already exist.) > > ChrisA Cython is out of question since link time dependencies has to be kept at an utmost minimum. An concerning doing things from python code it's simply not possible (or I don't know how this should work). Python is fully embedded including any file actions (virtual file system). The launch comes from C++ land. No interpreter is involved. The main work is done outside Python and only dropped in python to do higher logic. This also means the very first python code run requires a C++ script file loading before this first code can ever run. I can't run code that doesn't yet exist in the reach of the python VM. That's the main problem. This is why I need to figure out how to push that first code into Python in a way I can construct an object (from a predefined class). From there on all calls into Python land are solely done trough function calls on this one object obtained in the beginning. I see no other way to handle the problem. -- Yours sincerely Plüss Roland Leader and Head Programmer - Game: Epsylon ( http://www.indiedb.com/games/epsylon ) - Game Engine: Drag[en]gine ( http://www.indiedb.com/engines/dragengine , http://dragengine.rptd.ch/wiki ) - Normal Map Generator: DENormGen ( http://epsylon.rptd.ch/denormgen.php ) - As well as various Blender export scripts und game tools
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Loading modules from files through C++ Roland Plüss <roland@rptd.ch> - 2014-05-19 18:37 +0200
csiph-web