430
❘
APPENDIX A
IronPython DIfferences wIth cPython
moDulE NAmE
mISSINg or cHANgED?
NoTES
strop
Missing
Provides support for common string operations. This
module is optimized for speed. You can read more
about this module at
http://pydoc.org/2.5.1/
strop.html
.
xxsubtype
Missing
Presents an example of how to subtype built-in
C types. You can read more about this module at
http://pydoc.org/2.5.1/xxsubtype.html
.
zipimport
Missing
Defines a method for importing modules from
ZIP files. You can read more about this module at
http://pydoc.org/2.5.1/zipimport.html
and
http://docs.python.org/library/
zipimport.html
.
uSINg cuSTom cPyTHoN EXTENSIoNS
Getting your CPython extension to work with IronPython could prove difficult. In fact, you can’t
ever make compiled extensions, those with the
.pyc
file extension, work with IronPython because
it simply doesn’t provide the required support. If your custom extension is written in pure Python
and doesn’t rely on any of the missing modules found in Table A-2, then it may very well work
with IronPython.
You don’t need to slog through the process of creating a solution for a custom
CPython extension alone. The Google group at
http://groups.google.com/
group/c-extensions-for-ironpython
can provide assistance with your cus-
tom CPython extension needs. In addition, some companies such as Resolver
Systems are looking for ways to make using CPython extensions a lot easier (see
the press release at
http://www.resolversystems.com/news/?p=17
).
It’s important to consider, however, that direct access limitations need not mean a complete lack of
access. For example, you could always write an extension wrapper using C# or Visual Basic.NET
using the technique found in the “Using C# for Win32 Support” section of Chapter 16. Using P/
Invoke makes it possible to access code that IronPython couldn’t ordinarily access. For this solution
to work, however, you must have a detailed knowledge of how the CPython extension works.
In some cases, you might find a third-party alternative for the CPython extension you want to use.
This solution is becoming more common every day as other developers find that they require access
to a particular CPython module that IronPython doesn’t support.
TABlE A-3
(continued)
548592bapp01.indd 430
2/24/10 12:49:59 PM
www.finebook.ir
Do'stlaringiz bilan baham: |