Python and Jython are kinda different

Jp Calderone exarkun at intarweb.us
Fri Jan 9 20:49:01 EST 2004


On Fri, Jan 09, 2004 at 11:11:36PM -0000, Dave Benjamin wrote:
> In article <8765fkrig3.fsf at pobox.com>, John J. Lee wrote:
> > Yes, but it has been specifically noted by GvR (as well as the
> > Jythonistas) that Jython is lacking developers ATM.
> 
> I see.
> 
> >> represented in books and tutorials--just two implementations of the Python
> >> language, we all ought to be more concerned with unifying them. I never see
> >> Jython advertised as a limited subset of Python.
> > 
> > Well, it's *not* a limited subset of CPython 2.1 (apart from tiny
> > differences).
> 
> True. I suppose this brings up the following question: What *is* "Python"?
> Does the concept of Python *today* fit within Jython's feature set? I'd say
> much of it does, but a few things stick out, in order of decreasing
> importance (IMHO):
> 
>  - generators

  All generators can be re-written with classes using the iterator protocol. 
Here's a simple example:


    # As a generator
    def foogen():
        yield 1
        yield 'a'
        yield []

    # As classes using the iterator protocol
    class _FooGenIterator:
        counter = 0

        def next(self): return getattr(self, 'state_%d' % self.counter)()
        def state_0(self): return 1
        def state_1(self): return 'a'
        def state_2(self): return []
        def state_3(self): raise StopIteration

    class FooGen:
        def __iter__(self):
            return _FooGenIterator()

    # Used exactly the same
    for i in foogen(): print i
    for j in FooGen(): print j

>  - properties

  This is getting closer, I think.  More generator, descriptors are pretty
honkin' fundamental these days.  On the other hand, most behavior
acheivable with properties can be achieved with __g/setattr__, albeit it
quite as conveniently.

>  - getattr/getitem behavior (which is even different from CPython 2.1)

  I guess I haven't used Jython enough to know what's going on here.

>  - type factories being classes

  This seems pretty important to me, probably the most important on the
list.  Metaclasses existed before 2.2, but not without writing an extension
module.

>  - dictionary support for "in" keyword

  This seems pretty trivial to me. It's just a transformation of
dict.has_key().

> [snip]
> 
> > I believe GvR said that PyPy might (might!) become a sort of
> > executable standard for Python in the future, though.
> 
> I think that's an impressive idea, but it almost seems like the resources
> spent in keeping PyPy and CPython in parallel could be better spent keeping
> Jython and CPython in parallel, seeing as nobody is calling PyPy "Python"
> currently.
> 

  Can't say I agree here, probably because I don't much care about Java ;)
I think PyPy has a lot more bang for the buck for your average Python
programmer.  Jython might be nice to bring in some of the Java people, or
make some of that Java work easier when you absolutely have to use it, but
for your average Python application, it hardly enters into the picture. 
PyPy, on the other hand opens up a lot of possibilities for future
improvements to the language (because it is easier to prototype new features
in Python than in C) as well as improvements to existing features.


  Jp




More information about the Python-list mailing list