Saturday, January 09, 2010

Templates on Pydev (with Jython scripting)

One really nice feature that has just been added to Pydev (available in the nightly build) is the possibility of extending the variables that are available for templates through Jython scripting.

It opens lots of possibilities, as when it's resolved it has access to the python code being edited (and all the available modules and Pydev APIs).

Some default templates were added already taking advantage of that (see: pytemplate_defaults.py as a reference -- the docstring explains how to create your own templates).

The image below shows the variables created in the defaults (already using Jython scripting -- note that when multiple superclasses are available, the ${superclass} variable enables the user to choose which one to use):





This enabled the print template to work as expected (giving only 'print ' in python 2.x and 'print()' in python 3.x, as it can 'know' which grammar you are using).

To finish, 2 other templates were creating taking advantage of the context:
super : super(MyClass, self).CurrentMethod()
super_raw : MySuperClass.CurrentMethod(self)

If anyone has other 'must have' template suggestions now that this is available, those are very welcome.

On a side note, the current nightly build is pretty stable (and should be the new released version unless there's some critical error lying there found in the next 2-3 days), so, it should be safe to get it to experiment with those.

Wednesday, December 09, 2009

Pydev 1.5.2 and 1.5.3 released

Just to note, Pydev 1.5.3 was a 1 bug fix release, fixing an annoying bug (an error would be print to the console when running on python -- although everything would still work as expected).

As for 1.5.2, the changes were focused a lot on memory and performance improvements (special thanks to the Eclipse Memory Analyzer, it really helped a lot).

Basically, Pydev had some memory peaks when analyzing modules, because it expected Eclipse to properly manage Jobs created (which are basically threads managed by Eclipse), but it turns out things were not so straightforward, so, say that you changed 500 files (in a source-format operation), it would happily go on and try to create 500 threads in the analysis (that's now fixed).

Other memory savers were targeted at handling Strings (which are 'sort of' internalized now when parsing the code, but without using PermGen space). And not keeping references to Tokens from the parsing alive (because any reference to any Token would keep all alive).

On the performance side, some changes were done to the grammar to make it a bit faster (that area had already been profiled a lot, so, there are not many performance improvement opportunities there).

Aside from that, the compare editor now has proper syntax highlighting, indentation handling and code completion from the Pydev editor. And as usual, some other minor niceties and bug fixes are available.

Tuesday, November 24, 2009

PyQt4 bug preventing it from working properly in Pydev (and workaround)

Hi All,

There have been some reports on people with problems to get PyQt4 working properly in Pydev... This is because depending on the version of PyQt4 it has a major bug that will crash a Python interpreter (this was confirmed in version 4.5.4 -- haven't checked on other versions).

To know if you have a version with this problem you can check it by running the code below in an interactive session:

>>> from PyQt4.QtCore import *
>>> QSignalMapper

>>> import inspect
>>> inspect.ismodule(QSignalMapper) <-- this will make the interpreter
crash!

If that's your problem, right now you have to fix Pydev by editing

eclipse/plugins/org.python.pydev/PySrc/importsTipper.py at line 154,
changing:
"for d in dirComps:"

to:

for d in dirComps:
    if d == 'QSignalMapper':
        continue

Or get another PyQt4 version.

Thursday, November 19, 2009

Pydev 1.5.1 released

Yeap, this release took more time than usually, but I hope it was worth it. The major things as I posted previously were related to the refactoring engine.

There were also a number of other minor problems and features done along the way.

The complete info may be found at: http://pydev.org/

So, now that it's out, what's next?

Well, the last releases were all about giving more power to the user (refactoring, jump in the debugger, app engine, merging pydev extensions to pydev, IronPython support -- did I mention that the pydev debugger is now working with the latest IronPython?), so, I think that now would be a good time to step back a little and work on ironing out the bugs and making some profiling sessions (for both speed and memory).

Wednesday, November 11, 2009

Pydev 1.5.1 almost there

Ok, all the planned changes for 1.5.1 are now in place and the current version already seems pretty stable, so, the current nightly build (available as an update site at http://pydev.org/nightly) will be the final version unless there's some critical bug found (so, if there's anyone interested, it'd be nice testing that version).

The major changes were:

- Improvements in the AST rewriter
- Improvements on the refactoring engine (no longer using BRM, merged with the latest PEPTIC and added/fixed lots of cases for corner-case situations)
- Improvement in the type inference engine for lists

And along that there were a good number of minor editor improvements and bug-fixes.