Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71678
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'string.': 0.05; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:files': 0.09; 'subject:modules': 0.09; 'used.': 0.09; 'python': 0.11; 'easier.': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'in- memory': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'situation.': 0.16; 'module': 0.19; 'implementing': 0.19; 'stefan': 0.19; 'code,': 0.22; 'memory': 0.22; 'load': 0.23; 'header:User-Agent:1': 0.23; 'looks': 0.24; '(or': 0.24; "i've": 0.25; 'source': 0.25; 'script': 0.25; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'code': 0.31; 'loading': 0.31; 'though.': 0.31; 'supposed': 0.32; 'interface': 0.32; 'regular': 0.32; 'url:python': 0.33; 'totally': 0.33; 'subject:from': 0.34; "can't": 0.35; 'anybody': 0.35; 'received:84': 0.35; 'but': 0.35; 'c++': 0.36; 'method': 0.36; 'url:org': 0.36; 'integration': 0.37; 'implement': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'does': 0.39; 'embedded': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; 'url:3': 0.61; 'name': 0.63; 'skip:n 10': 0.64; 'finally': 0.65; 'within': 0.65; 'between': 0.67; 'url:4': 0.69; 'received:arcor-ip.net': 0.84; 'received:pools.arcor-ip.net': 0.84; 'step.': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Stefan Behnel <stefan_ml@behnel.de> |
| Subject | Re: Loading modules from files through C++ |
| Date | Sat, 17 May 2014 13:58:53 +0200 |
| References | <5376ACE7.8030706@rptd.ch> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | dslb-084-056-038-254.pools.arcor-ip.net |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
| In-Reply-To | <5376ACE7.8030706@rptd.ch> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10081.1400327955.18130.python-list@python.org> (permalink) |
| Lines | 26 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1400327955 news.xs4all.nl 2910 [2001:888:2000:d::a6]:43185 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:71678 |
Show key headers only | View raw
Roland Plüss, 17.05.2014 02:27: > I'm using Python in an embedded situation. In particular I have to load > python scripts through a memory interface so regular python module > loading can not be used. I got working so far a module loader object > I've added using C++ to sys.meta_path . Now I'm totally stuck at the > finally loading step. > > I've got this a C++ loader method "load_module(fullname)" which does > load the requested module script files into a null-terminated string. I > know that "load_module" has to return the module PyObject*. But I can't > get the python source in the c-string into a module PyObject*. > [...] > Can anybody help how in gods name one is supposed to create a module > from an in-memory c-string when called from within load_module (or > anywhere)? Looks like you want to implement a SourceLoader: https://docs.python.org/3.4/library/importlib.html#importlib.abc.SourceLoader I recommend implementing this in Python code instead of C code, though. Much easier. Cython can help with the integration between both. Stefan
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Loading modules from files through C++ Stefan Behnel <stefan_ml@behnel.de> - 2014-05-17 13:58 +0200
csiph-web