FAQ
I'd like to extend Python and I'm not yet sure if it would
be best to use COM (of which I know next to nothing) or
a different method.

I'd like to extend it for both Mac and Windows and it would
probably be best to use methods as similar as is possible
for these two environments, though it may not be easy....

Is there an equivalent to Com on the Mac which works,
would work, with Windows?

I *think*, from reading the docs, is that the easiest way for
me to add my own functions to Python on both the Mac and
Windows is for me to statically link the new functions into
the Python source.

Any ideas/comments?

--
Owen F. Ransen
http://www.ransen.com/
Home of Gliftic & Repligator Image Generators

Search Discussions

  • Pete Shinners at Apr 24, 2001 at 4:38 pm
    "Owen F. Ransen" <ransen_spam_me_not at nemo.it> wrote
    I'd like to extend Python and I'm not yet sure if it would
    be best to use COM (of which I know next to nothing) or
    a different method.
    i wouldn't do it with static recompiling. most people aren't
    too hip on rebuilding their python core just for a new module
    (especially on Win and Mac (unix is a little better))

    look into the distutils. they have been shipping with python
    since 2.0, and now in 2.1 they have support for macos and
    metrowerks.

    first dipping your toes into distutils can take a bit of learning,
    but look for some examples and the docs, and you won't be in any
    trouble.
    http://www.python.org/doc/current/dist/dist.html

    this will build your extension as a shared library, and get
    it all installed properly. from there you are all set to go.
  • Darrell at Apr 25, 2001 at 12:40 am
    Unless you're wrapping existing code, do new work in Python first.
    Then if you really, really must, and have no other choice.
    Take a look at a 'C' extension.
    Often it's not worth the head ach to code it in 'C'.

    Someone won't like this, but I'd avoid COM.
    Unless you share your components with VB developers or the like.
    For reuse in a Python environment .py files are great.

    Several times now I've converted 'C' and Java apps to Python.
    Once you get rid of the visual noise those languages come with.
    A simplified solution may fall out.

    Oh, don't I whish C++ required you use this->xyz
    --Darrell


    "Owen F. Ransen" <ransen_spam_me_not at nemo.it> wrote in message
    news:3ae64b92.1979659 at news.newsguy.com...
    I'd like to extend Python and I'm not yet sure if it would
    be best to use COM (of which I know next to nothing) or
    a different method.

    I'd like to extend it for both Mac and Windows and it would
    probably be best to use methods as similar as is possible
    for these two environments, though it may not be easy....

    Is there an equivalent to Com on the Mac which works,
    would work, with Windows?

    I *think*, from reading the docs, is that the easiest way for
    me to add my own functions to Python on both the Mac and
    Windows is for me to statically link the new functions into
    the Python source.

    Any ideas/comments?

    --
    Owen F. Ransen
    http://www.ransen.com/
    Home of Gliftic & Repligator Image Generators
  • Courageous at Apr 25, 2001 at 1:10 am

    Unless you're wrapping existing code, do new work in Python first.
    Then if you really, really must, and have no other choice.
    Take a look at a 'C' extension.
    Often it's not worth the head ach to code it in 'C'.
    An old quote, who's origin I've forgotten: "premature
    optimization is the root of all evil." Which is to say,
    profile your code first, then consider external C functions
    for the things which actually consume CPU time.

    BTW, to the original poster: the more work your code
    can do in C once it gets there, the better. Python carries
    significant overhead in dispatching to your external code.
    If you external function is meant to do very small amounts
    of work over very frequent invocations, external functions
    aren't as obvious a choice and the benefits aren't nearly
    as dramatic as you predict.

    Conversely, things which do very large amounts of work
    can push Python programs to at-or-near C speeds when
    done right. Calculations in Numeric Python (and friends)
    come to mind.

    C//
  • Darrell at Apr 25, 2001 at 2:08 am
    Just had an example of this in this thread "Help me use re better"
    Where it was faster to stay in the regular expression engine than to loop
    though it.

    --Darrell

    "Courageous" <jkraska1 at san.rr.com> wrote in message >
    BTW, to the original poster: the more work your code
    can do in C once it gets there, the better. Python carries
    significant overhead in dispatching to your external code.
    If you external function is meant to do very small amounts
    of work over very frequent invocations, external functions
    aren't as obvious a choice and the benefits aren't nearly
    as dramatic as you predict.

    Conversely, things which do very large amounts of work
    can push Python programs to at-or-near C speeds when
    done right. Calculations in Numeric Python (and friends)
    come to mind.

    C//

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedApr 24, '01 at 9:50a
activeApr 25, '01 at 2:08a
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase