inicio mail me! sindicaci;ón

Pinder 0.6.5

In this new release of my Campfire API, Pinder 0.6.5, I fixed some bugs and added the methods ping() and topic() (which matches change_topic()) to the Room objects.

There is by the way an incompatible change: I do not distribute anymore BeautifulSoup and httplib2 with the library.

Go take it!

Twitter page for PyCon Italy

I opened a Twitter account for the PyCon Italy conference. I will try to keep updated as soon as things come up and the conference starts on Friday.

http://twitter.com/pyconit

share11 with Google AppEngine

While I was boring myself to death last weekend and while everybody was talking about it I came up with a sample application.

Now I can talk about Google AppEngine as well :-)

It is simply a pastebin using the DataStore API, the webapp framework, the Users API, pygments and Django templates.

It is heavily inspired by http://dpaste.com

http://share11.appspot.com

The great thing? It took me less than an afternoon (mostly reading the framework docs) and it is ~200 LOC. Even greater? One shell command to upload and deploy :-)

PyCon Due schedule updates

We had to make some schedule updates for the conference.

The savory new flavor of Py2.6 and Py3.0 is the title of the second day’s keynote. Who’s the speaker? Raymond Hettinger :-)

The talk about callbacks and Python patterns have been replaced by a talk about the now utterly famous Google AppEngine.

The speakers of the PyPy talk are Antonio Cuni and Samuele Pedroni.

The title of Stallman’s keynote is Free Software in ethics and in practice.

PyCon Due schedule is out

UPDATE: Raymond Hettinger will hold the keynote of the second day!

PyCon Due is definitely taking shape.

The conference will take place on a three day span.

The first day venue (free of any kind of charge) will be Palazzo Vecchio, in Florence. The conference will be introduced by the spokeswoman of Arts of the city. The opening keynote will be given by Richard Stallman, a person who needs no introduction in the software world.

After that, which is definitely important, we plan to go out and eat all together at a restaurant. Social life is equally important :-)

The actual conference will begin the next day, the 10th of May, divided in three parallels track: a tutorial track, an introduction one and one based on experiences and real life usage of the language.

We’ll have talks about Python for beginners, various incarnations of Python, Plone, information retrieval, PyQt, nginx and WSGI, Cython, advanced uses of Django, PyMaemo, Unicode, PyPy, Zope 3 and more on that day. There will be also a Skype sponsored talk about Skype4Py.

The second day will be full of talks about profiling and debugging, SQLAlchemy, Django again, callbacks and patterns, map sharing, concurrency, Twisted Matrix, IronPython, Ajax, compilers in Python, the Fedora Unified Network Controller, FlyPDF and component architectures and more.

As you can imagine will be a tough three days conference, one an Italian (Python) developer should not miss in my opinion.

A lot of well known speakers: Alex Martelli (another who needs no introduction), Federico di Gregorio (author of psycopg2), Arkadiusz Wahlig (author of Skype4Py), Manlio Perillo (of nginx’s mod_wsgi fame), Antonio Cuni (from the PyPy team), Giovanni Bajo (mantainer of PyInstaller and of GCC fame), Brian Fitzpatrick (Subversion anyone?), Menno Smits (from the Resolver Systems team), Michele Simionato (of metaclasses, decorators and mro fame) and more.

As part of the board of the conference I’m a little biased by I’m really looking forward for this one ;-)

See you there!

PyCon Due is coming

UPDATE: I forgot to say that there will be simultaneous translation for non-italian speakers and attendants.

PyCon Due Italy is coming, here the press release (in Italian):

Firenze, 27 Marzo 2008: Sono finalmente aperte le iscrizioni a PyCon Due, la seconda conferenza italiana dedicata al linguaggio di programmazione Python, che si terrà a Firenze il 9, 10 e 11 Maggio 2008.

Dopo il largo successo di pubblico e critica ottenuto da PyCon Uno l’anno scorso, l’Associazione di Promozione Sociale “Python Italia” organizza quest’anno un evento ancora più ambizioso. Sono attesi infatti più di 300 tra professionisti, studenti e ricercatori, per una tre giorni intensa di appuntamenti e interventi imperdibili.

L’evento di apertura si svolgerà Venerdì 9 Maggio alle ore 15:00 nel prestigioso Salone De’ Cinquecento in Palazzo Vecchio dove, dopo il saluto da parte di Lucia De Siervo (Assessore all’Informatizzazione del Comune di Firenze, che ha donato all’evento il suo Patrocinio), Richard Stallman (fondatore del movimento del Free Software, inventore della licenza GPL e ideatore del progetto GNU) terrà un keynote sul tema “Free Software e Free Ethics”. Questo evento di apertura è ad ingresso libero (fino ad esaurimento posti, ma con priorità a chi è registrato al PyCon).

In seguito, nelle giornate di Sabato 10 e Domenica 11, all’Auditorium Al Duomo, si terranno numerose conferenze dedicate al linguaggo Python, su tre track parallele. Parteciperanno speaker internazionali di fama mondiale come Alex Martelli, Samuele Pedroni, Brian Fitzpatrick, e molti altri. Sono previsti anche interventi dedicati a programmatori che si avvicinano al linguaggio per la prima volta.

Inoltre, sono previste sessioni speciali come la sessione di recruiting (dedicate ai programmatori in cerca di nuova occupazione, e alla quale parteciperanno le aziende con posizioni lavorative aperte), momenti di svago e relax serale, e l’estrazione di regali offerti dagli sponsor (che includono aziende di caratura internazionale come Skype e Google).

Per maggiori informazioni, potete visitare il sito Internet ufficiale dedicato all’evento. Registrandosi in anticipo, inoltre, sono previsti forti sconti sul biglietto d’ingresso.

If you are at least midly interested in the Python word, come!

If XML-RPC is really better than REST, it’s not for there reasons.

Dave Benjamin summarized on his blog 10 reasons why XML-RPC should be better than REST but I think he completely missed the point about REST APIs. Let’s see:

1 - Standard, cross-language, typeful serialization of data

REST is definitely standard and cross-language. Regarding serialization, you can transfer what you want where you want but if your goal is persisting to make a local resemblance of what you have remotely, I think that’s bad. What we, as developers, really care is having the possibility to use a service remotely with an eye on scalability and transparence. Hence, HTTP ;-)

2 - User-defined error codes and messages

Nobody forbids anyone to invent your own headers and place whatever meaning you want upon them. With HTTP you can surely do that. Even whole extensions have been written.

3 - “Boxcarring” of requests to reduce overhead

Box carring is not really an advantage, there are other ways to reduce overhead. See also 207 multi status

4 - Serialization of binary content

Who said REST protocols do not support binary data? You can send whatever you want from the client to server, place the right content type and you’re done. See also media resources in the Atom Publishing Protocol.

5 - Serialization of date-time values

Do I really have to answer that?

6 - Standardized parameter passing

And what if I want to pass a parameter that’s not on the list of the allowed types in the specification? Remember, SOAP has born also to address some of the limitations of XML-RPC.

7 - Introspection allowing for straightforward code generation

Let me say one thing once and for all. Code generation for this purposes is bad, and almost useless (if you are used to highly dynamic languages). Anyway, REST through hypertext is implicitly introspection enabled. Also, documentation of APIs is there for us ;-)

8 - High-level APIs for just about every language

I think there’s no need to say that each and every language has some sort of HTTP client.

9 - No manual parsing of XML, ever

This point does not really make sense to me. If one XML-RPC method does return XML as content, you have to parse it because is part of the application domain. The same for SOAP or REST. If, as Dave mentioned, the language has some sort of high-level API for the protocol you don’t have to parse what’s on the wire manually: no manual parsing of XML-RPC responses, or SOAP envelopes or HTTP responses.

10 - Only three lines to call a function in Python and several other languages

This is really pointless. Using a REST API from httplib2 or restclient has the same brevity.

I think Dave did not get REST at all, his conclusion speaks for him:

Not that the REST doesn’t have its benefits, but someone ought to be saying this. XML-RPC isn’t complicated like SOAP, it runs just about everywhere, and it lets you get on with your work rather than arguing about semicolons versus slashes or XML versus JSON or countless other things. Besides, when your goal is to support as many languages as possible, you want to minimize the amount of code you write for each language. As far as I’ve seen, nothing else accomplishes literally no-code binding like XML-RPC.

I suggest reading RESTful Web Services, it’s really a good book. I also suggest reading the last article wrote by Stefan Tilkov addressing the most popular REST doubts.

Updates from Python SVN, Part 19

Here we are with another update from Python 2.x SVN.

  • Added os.O_NOATIME constant. It serves the purpose to not update the access time within read operations.

  • Added os.fchmod() and os.fchown().

  • The new module has been deprecated. Use types instead.

  • sys.py3kwarning flag has been exposed. True when python is started with -3 flag on command line. Also warning.warnpy3k() has been added to help the transition.

  • Added PyFloat_GetMax, PyFloat_GetMin, PyFloat_GetInfo to the C API and float_info dictionary to the sys module which contains information about the internal floating point type.

  • Added test suite for the cmd module.

  • Added Python on Windows documentation.

  • Implemented PEP 366 (Main module explicit relative imports).

  • Support loading pickles of random.Random objects created on 32-bit systems on 64-bit systems, and vice versa. As a consequence of the change, Random pickles created by Python 2.6 cannot be loaded in Python 2.5.

  • Changed GeneratorExit’s base class from Exception to BaseException.

  • os.access now always returns True on Windows for any existing directory since there are no read only directories on Windows.

  • Added msvcrt.getwch(), msvcrt.getwche(), msvcrt.putwch(), msvcrt.ungetwch() to handle wide chars.

  • namedtuple.asdict and namedtuple.replace are now namedtuple._asdict() and namedtuple._replace()

  • Dictionary construction had a speed-up of about 10%. There is a new opcode, STORE_MAP that saves the compiler from awkward stack manipulations and specializes for dicts using PyDict_SetItem instead of PyObject_SetItem. From the log message:

Old disassembly:
              0 BUILD_MAP                0
              3 DUP_TOP             
              4 LOAD_CONST               1 (1)
              7 ROT_TWO             
              8 LOAD_CONST               2 ('x')
             11 STORE_SUBSCR        
             12 DUP_TOP             
             13 LOAD_CONST               3 (2)
             16 ROT_TWO             
             17 LOAD_CONST               4 ('y')
             20 STORE_SUBSCR 

New disassembly:
              0 BUILD_MAP                0
              3 LOAD_CONST               1 (1)    
              6 LOAD_CONST               2 ('x')
              9 STORE_MAP                
             10 LOAD_CONST               3 (2)  
             13 LOAD_CONST               4 ('y')
             16 STORE_MAP
  • Another optimization has been added: BUILD_MAP now has a meaning. It’s the estimated size of the dictionary. Allows dictionaries to be pre-sized (upto 255 elements) saving time lost to re-sizes with their attendant mallocs and re-insertions. Has zero effect on small dictionaries (5 elements or fewer), a slight benefit for dicts upto 22 elements (because they had to resize once anyway), and more benefit for dicts upto 255 elements (saving multiple resizes during the build-up and reducing the number of collisions on the first insertions). Beyond 255 elements, there is no addional benefit.

  • Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for compatibility are available.

  • Added signal.set_wakeup_fd(). There is a correspondent C API as well: PySignal_SetWakeupFd.

  • Slightly change in __ hash __ behavior and rich comparison: __ hash __ can be inherited when one __ lt __, __ le __, __ gt __, __ ge __ are overridden, as long as __ eq __ and __ ne __ aren’t.

  • Improved performance of built-in any()/all() by avoiding PyIter_Next().

Updates from Python SVN, Part 18

IT’s been definitely a while since my last update but having a new job changes a lot my schedule.

  • In the httplib module there was a bug in reading data from the stream. HTTPConnection hanged when reading too much data at once. This has been fixed closing the connection after reading the whole stream.

  • In the decimal module the tuple constructor is now less permissive. It allowed bad coefficient numbers, floats in the sign and other stuff which generated the wrong number or let the algorithms misbehave.

  • mmap() has a new offset parameter to map a window of a file.

  • named_tuple has been renamed to namedtuple.

  • The sum() builtin function has been optimized for integer and floats: it keeps temporary sums in C instead of new Python objects assuming operands are all of the same type. If not, goes back to the default routine.

  • os.environ.pop() and os.environ.clear() now call unsetenv() for a correct behavior.

  • Added support for FreeBSD 8.

  • Added mp4 to mimetypes.py.

  • Various fixes in the bsddb module (like bsddb.dbshelve using the highest pickle protocol and more).

  • Fixed marshal’s incorrect handling of subclasses of builtin types.

  • Added set/frozenset’s isdisjoint(): returns True if two sets have a null intersection.

  • Added getter, setter, deleter methods to properties that can be used as decorators to create fully-populated properties.

  1. class C:
  2.     foo = property(doc=“hello”)
  3.     @foo.getter
  4.     def foo(self):
  5.         return self._foo
  6.     @foo.setter
  7.     def foo(self, value):
  8.         self._foo = abs(value)
  9.     @foo.deleter
  10.     def foo(self):
  11.         del self._foo
  12. c = C()
  13. assert C.foo.__doc__ == “hello”
  14. assert not hasattr(c, “foo”)
  15. c.foo = -42
  16. assert c.foo == 42
  17. del c.foo
  18. assert not hasattr(c, “foo”)
  1. Python 2.6a0 (trunk:59170M, Nov 24 2007, 15:06:35)
  2. >>> a = “pippoplutarca”
  3. >>> a.find(‘t’, None, None)   
  4. 8
  5.  
  6. Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
  7. >>> a = “pippoplutarca”
  8. >>> a.find(‘t’, None, None)
  9. Traceback (most recent call last):
  10.   File “<stdin>”, line 1, in <module>
  11. TypeError: slice indices must be integers or None or have an __index__ method
  • Directories and zipfiles containing a _ main _.py file can now be directly executed by passing their name to the interpreter. The directory/zipfile is automatically inserted as the first entry in sys.path.

  • Abstract base classes have been backported to Python 2.6.

  • Python 2.6 is now compilable with Visual Studio 2008.

  • Major change in the internal structure of the Decimal number: now it does not store the mantissa as a tuple of numbers, but as a string. This avoids a lot of conversions, and achieves a speedup of 40%. The API remains intact.

Italian Agile Day is coming

Marco Abis has announced the 2007 edition of the Italian Agile Day. I’ve been to the 2006 edition and I have to admit it was great. The talks were all about Scrum, Team management, TDD, ORM and agility, code metrics, distributed projects and agility, code and DB refactoring, XP games, mock objects, agility and Visual Studio Team System, agile web development with Django and more.

I hope the 2007 edition wil be even more interesting :-).

See you in Bologna on November, the 23rd.

Next entries »