Services Blog Français

Using rst for documentation on both GitHub and Sphinx/RTFD: code-block tip

| by jpic | python documentation service

Good documentation should be readable from source, and usable to generate fancy HTML. That’s why RST is so commonly used:

  • readable as text source,
  • usable to generate HTML and even PDF
  • GitHub knows how to render it,
  • Sphinx and ReadTheDocs know how to render it.

Good documentation should often show code. This article demonstrates an inconsistency between RTFD and GitHub rendering, and how to fix it.

As far as sphinx is concerned, the default highlight language for code blocks is Python. This will render as Python on Sphinx/RTFD:

Read More

Django development: possible change of the .save() implementation

| by jpic | django-developers django

An interesting topic by Anssi Kääriäinen flew by django-developers mailing list about ticket #16649: “Models.save() refactoring: check updated rows to determine action”.

The ticket mentions a 50% performance optimization. Here’s an explanation by akaariai (core developer):

A bit more information about what the approach suggested is about. Assume you load a model from DB, change some fields and save it. We currently do:

SELECT - load from DB
[change fields]; save()
In save:
    SELECT - assert that the PK exists in the DB
    if yes:
        UPDATE
    else:
        INSERT

The second select above is usually redundant. If we know the object is loaded from DB (self._state.adding == False), and we are saving it to the same DB it was loaded from (self._state.db == the db we are saving to), then it is very likely the object exists in the DB. So, instead we should do:

Read More
Previous Page 29 of 33 Next Page

They trust us

Contact

logo