4. What do we need?
• A time, space & some drinks
• Subjects / Format
• You!
• Please invite and suggest
5. How do you use python?
• For how long?
• Web
development?
• As main language?
• Framework?
6. Contents
• Any subject you’d like to hear about?
• Any subject you’d like to talk about?
python 3.0 web services
django 1.4 data migration
performance tuning
9. Ivor Bosloper
using Geodjango
Preferred general purpose language:
Basic/
Assembler C Java Python
1985 1995 2001 2010
10. Java2py
Disclaimer: I love Java/JVM
• Typesafe/checked references
• Garbage collection
• Object Oriented
• Huge API
• General purpose
• Security, i18n
• Great debugging (e.g. with stacktraces)
20. Pragmatic APIs
• APIs created for use, not for possibilities
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File("file.xml"));
XpathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
NodeSet books = (NodeSet) xpath.evaluate("/Books/Book",doc,XpathConstants.NODESET);
21. Pragmatic APIs
• APIs created for use, not for possibilities
InputStream imageInputStream = FileInputStream("c.jpg");
SeekableStream seekableImageStream = SeekableStream.wrapInputStream(imageInputStream, true);
RenderedOp originalImage = JAI.create(JAI_STREAM_ACTION, seekableImageStream);
((OpImage) originalImage.getRendering()).setTileCache(null);
int origImageWidth = originalImage.getWidth();
double scale = 220.0 / originalImage.getWidth();
ParameterBlock paramBlock = new ParameterBlock();
paramBlock.addSource(originalImage); // The source image
paramBlock.add(scale); // The xScale
paramBlock.add(scale); // The yScale
paramBlock.add(0.0); // The x translation
paramBlock.add(0.0); // The y translation
RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
RenderedOp resizedImage = JAI.create(JAI_SUBSAMPLE_AVERAGE_ACTION, paramBlock, qualityHints);
// lastly, write the newly-resized image to an output stream, in a specific encoding
FileOutputStream encoderOutputStream = new FileOutputStream("c-thumb.jpg");
JAI.create(JAI_ENCODE_ACTION, resizedImage, encoderOutputStream, JAI_ENCODE_FORMAT_JPEG, null);
I would like to talk about two things : the idea of organizing python meetings : Do the kick-off presentation myself
Would like to call it groningen.py (after groningen.rb) The purpose is to talk and learn about python usage
Let me know if you have ideas on any of the above.
Quick scan: how do you use python We don’t need definitive answers
I prefer to hear from experience, over tutorial style talks
My name is Ivor Bosloper A few months ago I started a company called Crop-R. We’re building a product for farmers and developing it in GeoDjango. We all use a load of languages, but if you’d ask me: what’s your preferred general purpose language I’d come up with this answer. Only very recently I switched from Java to Python.
I would still consider Java for many projects. (reference, gc, oo, API, general purpose). This all holds for Python as well…
I wanted to make this talk experience driven, so not a theoretic comparison. Let me know at the end if I succeeded. Still love Java but prefer python
Developers spend 80% of their time reading code.
Hello world starts showing it. But I don’t like theoretic examples, so let’s take some example code from a project
Repetitiveness. Verbosity.
Powerful language: you don’t need configuration languages
Inefficient. Unreadable.
And worse: you have to think of everything in advance! It’s not a programming language (executes some logic). E.g. servlet-mapping has strict rules. You can not do random pattern matching!
The language has some nice constructs to make your code really concise. Declarative programming. Callbacks.
I want to be able to plugin a new XML Implementation.
What I miss (or don’t know): please Concurrency ( One big global lock )
I didn’t understand why no of the datastructutes (like dict) had concurrent behaviour documented. In Java, most datastructures have this part documented. Only after reading a bit I discovered there is no concurrency… ?! In CPython at least.
Java only crashes (in practice) on native code. That is: non-managed code. Java libraries