Two languages, too similar, competing in the same space.
Ron Stephens
rdsteph at earthlink.net
Thu Dec 27 18:36:15 EST 2001
I find this very interesting. Thanks for sharing it, it sounds very useful!
HarryO wrote:
> On Fri, 28 Dec 2001 09:56:29 +1100, Ron Stephens wrote:
>
> > ... But
> > now that Ruby is out there, it absorbs enormous mind share, and
> > development time to recreate libraries etc., which are already available
> > in Python, thus hurting Python.
>
> I have only tried it in a very minimal way, just to see that it did
> basically what was advertised, but you might be interested in this.
>
> There's a Ruby library that allows you to do things like:
>
> require 'python'
> require 'python/httplib'
>
> h = Py::Httplib::HTTP.new(host)
>
> h.putrequest('GET', path)
> h.putheader('Accept', 'text/html')
> h.putheader('Accept', 'text/plain')
> h.endheaders()
>
> Ie, the "require 'python'" makes pulling in Python libraries
> as simple as ...
>
> require 'python/SOME_PYTHON_LIB'
>
> which is almost as easy as doing it in Python.
>
> Similarly, referencing elements of such a library simply
> requires prefixing them with "Py::". Once you have a
> handle to a Python object, you call it the same way you
> would in Python. I don't think one could make it much simpler.
>
> So, to some extent, it's possible to avoid reinventing the
> wheel. How well this works, I can't say, just that the
> examples I played with worked as advertised.
>
> Obviously, there's some overhead, in that it's running a copy
> of the Python interpreter to execute the Python code, but so
> long as the work the library is doing for one is larger than
> the actual overhead of the call to it, that shouldn't be a
> problem.
More information about the Python-list
mailing list