2015-06-09 10:20 GMT+02:00 Yicong Huang <hengha....@gmail.com>: > "The interpreter gateway has more options for exposing interp-level > functions and types to app-level." > > How does this work? > We tried several builtin modules, as well as "select" module that you > mentioned, all thses modules's interp-level code are invisble to other > module's app-level. > > We would like to take your advices to make a new module. But the problem > is how to make the new module's interp-level code visible to app-level? >
See the "posix" module for example. Most functions are defined at interp-level, but there is also a file "app_posix.py" which just does "import posix" and happily calls interp-level code. > > > On Tue, Jun 9, 2015 at 9:30 AM, William ML Leslie < > william.leslie....@gmail.com> wrote: > >> On 8 June 2015 at 21:22, Yicong Huang <hengha....@gmail.com> wrote: >> >>> By reading modules in pypy/module, finally we found out the workaround >>> method. >>> >>> For most of modules in 'pypy/module', their interp code could not be >>> imported or used by other module's app code. >>> But there is special module '__pypy__', it exposed several interp >>> functions, and those code are used by other module's app code. >>> >> >> There's nothing special about __pypy__ for exposing interp-level code, >> the modules in pypy/modules usually include interp level code. >> >> For example, the select module exposes the interp-level function >> select_interp.select. Here's how it does so: >> >> >> https://bitbucket.org/pypy/pypy/src/b0c01840baea472c834635de627bb596c05d3bd5/pypy/module/select/__init__.py?at=default >> >> The interpreter gateway has more options for exposing interp-level >> functions and types to app-level. >> >> The workaround solution is simple: add one more interface in __pypy__ >>> module's __init__.py >>> >> >> You should make a new module rather than adding to one existing one. >> >> >>> PYC_MAGIC = get_pyc_magic(self.space) >> >> self.extra_interpdef('PYC_MAGIC', 'space.wrap(%d)' % PYC_MAGIC) >> >> >>> Are the above code do the magic thing to expose interp code? >>> >> >> They are exposing an integer value called PYC_MAGIC, which is the value >> for determining what python the .pyc file was compiled for. >> >> This is about exposing an integer rather than a function, it's probably >> not relevant to you. >> >> >> -- >> William Leslie >> >> Notice: >> Likely much of this email is, by the nature of copyright, covered under >> copyright law. You absolutely MAY reproduce any part of it in accordance >> with the copyright law of the nation you are reading this in. Any attempt >> to DENY YOU THOSE RIGHTS would be illegal without prior contractual >> agreement. >> > > > _______________________________________________ > pypy-dev mailing list > pypy-dev@python.org > https://mail.python.org/mailman/listinfo/pypy-dev > > -- Amaury Forgeot d'Arc
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev