| 1 |
PSEP: 5 |
| 2 |
Title: Guidelines for implementing backwards-incompatible changes |
| 3 |
Version: $Revision$ |
| 4 |
Last-Modified: $Date$ |
| 5 |
Author: Matti Airas <matti.p.airas@nokia.com> |
| 6 |
Status: Active |
| 7 |
Type: Process |
| 8 |
Content-Type: text/x-rst |
| 9 |
Created: 06-Oct-2009 |
| 10 |
|
| 11 |
|
| 12 |
Abstract |
| 13 |
======== |
| 14 |
|
| 15 |
There exists a strong interest for implementing new, partially |
| 16 |
backwards-incompatible API features to PySide. However, simply modifying |
| 17 |
the existing API would break any existing applications, so such |
| 18 |
modifications need to be done in a controlled manner. This PSEP sets the |
| 19 |
guidelines for implementing backwards-incompatible changes in PySide. |
| 20 |
|
| 21 |
Introduction |
| 22 |
============ |
| 23 |
|
| 24 |
The idea of improving the PySide API by making it more Pythonic was |
| 25 |
presented already during the project launch. Soon thereafter, several |
| 26 |
ideas were discussed, but at that point the design process and a clear |
| 27 |
implementation roadmap was still undefined. |
| 28 |
|
| 29 |
The planned API update coincides temporally with plans to implement Python 3 |
| 30 |
support in PySide. While these changes do not necessarily depend on each other, |
| 31 |
Python 3 requires considerable changes in PySide and is backwards-incompatible |
| 32 |
by itself. As the API changes have a similar scope, special emphasis will be |
| 33 |
placed on whether or not to perform both of the non-backward compatible changes |
| 34 |
together. |
| 35 |
|
| 36 |
This PSEP discusses the different proposed update strategies together |
| 37 |
with their pros and cons and then proceeds to select one specific |
| 38 |
strategy for the PySide API updates. |
| 39 |
|
| 40 |
API Update Strategies |
| 41 |
===================== |
| 42 |
|
| 43 |
Changing the existing API |
| 44 |
------------------------- |
| 45 |
|
| 46 |
The simplest method of updating the API is just to change the existing |
| 47 |
API. This is obviously very simple for the developers, and there exists |
| 48 |
only one API at any given time. However, any existing applications |
| 49 |
depending on PySide would need to be constantly updated. Any amount of |
| 50 |
such changes would in practice discourage any developers from using |
| 51 |
PySide, and therefore, this approach would only be possible at the very |
| 52 |
early stages of any project when there are not yet any applications |
| 53 |
using the project. |
| 54 |
|
| 55 |
Coinciding the API break with Python 3 transition |
| 56 |
------------------------------------------------- |
| 57 |
|
| 58 |
Python 3 is backwards incompatible with older Python versions both at |
| 59 |
the syntax and the standard library API levels. Since the users would |
| 60 |
need to adapt their code in any case, the thought of simultaneously |
| 61 |
updating the PySide API is an enticing one. The approach is tempting |
| 62 |
also from the API developers' perspective. Since Python 3 breaks the |
| 63 |
extension API compatibility in any case, this strategy cleanly splits |
| 64 |
the code to the old and the new APIs under the hood as well. |
| 65 |
|
| 66 |
On the other hand, one might argue that the tandem update strategy will |
| 67 |
actually be more difficult to implement in practice. Not only will there |
| 68 |
be changes due to the Python 3 transition, but the visible API behaviour |
| 69 |
will be changed as well. In practice, the two changes would need to be |
| 70 |
performed sequentially to implement the features in a controlled manner. |
| 71 |
|
| 72 |
The tandem update strategy would lead to a difficult upgrade path for |
| 73 |
existing applications. The recommended development model for upgrading |
| 74 |
from Python 2 to 3 is to utilize a specific ``2to3`` script to convert |
| 75 |
the script from Python 2.6 to the 3 syntax [#PEP-3000]_. This will not |
| 76 |
work if the APIs are modified in an incompatible manner at the same |
| 77 |
time. With the library APIs breaking simultaneously, the developer would |
| 78 |
have no idea whether the problems in his application are due to the |
| 79 |
Python or the PySide changes. |
| 80 |
|
| 81 |
When considering the alternatives, it is of importance that the tandem |
| 82 |
update strategy has been discouraged by Python core developers |
| 83 |
[#guido-re-incompat]_, to a great extent due to the reasons discussed |
| 84 |
above. |
| 85 |
|
| 86 |
|
| 87 |
Separate imports for different API versions |
| 88 |
------------------------------------------- |
| 89 |
|
| 90 |
The final API upgrade strategy is to disconnect the upgrade altogether |
| 91 |
from the Python version upgrade. In this case, the |
| 92 |
backwards-incompatible API would be placed in its own module. For |
| 93 |
example, the current ``QtCore`` library is imported using:: |
| 94 |
|
| 95 |
import PySide.QtCore |
| 96 |
|
| 97 |
The new API would then utilize a different import:: |
| 98 |
|
| 99 |
import PySideFoo.QtCoreBar |
| 100 |
|
| 101 |
This approach might arguably actually simplify implementing the new |
| 102 |
features as they would be only simple steps on top of the old API. |
| 103 |
Furthermore, Python 3 porting would only focus on the extension API |
| 104 |
differences instead of mixing the PySide API changes in the issue. |
| 105 |
For users, separate imports would provide for a standard upgrade path, |
| 106 |
removing any extra barriers for upgrading to Python 3. |
| 107 |
|
| 108 |
The main drawback in this approach is the potentially increased |
| 109 |
maintenance effort. Two sets of APIs on two major Python versions need |
| 110 |
to be maintained. This may tie down the developers and decrease general |
| 111 |
project velocity. |
| 112 |
|
| 113 |
Selected API update strategy |
| 114 |
============================ |
| 115 |
|
| 116 |
From the update strategy alternatives discussed in the previous section, |
| 117 |
the last one (separate imports for different API versions) will be |
| 118 |
chosen as the PySide update strategy. Having separate imports provides |
| 119 |
the safest upgrade path both for the internal PySide developers and for |
| 120 |
any projects depending on PySide. Any specifics such as the new import |
| 121 |
names will be dealt with in a separate PSEP. |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
References |
| 126 |
========== |
| 127 |
|
| 128 |
.. [#guido-re-incompat] Python 3000 and You, Van Rossum |
| 129 |
(http://www.artima.com/weblogs/viewpost.jsp?thread=227041) |
| 130 |
|
| 131 |
.. [#PEP-3000] PEP 3000, Van Rossum |
| 132 |
(http://www.python.org/dev/peps/pep-3000/) |
| 133 |
|
| 134 |
|
| 135 |
Copyright |
| 136 |
========= |
| 137 |
|
| 138 |
This document has been placed in the public domain. |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
.. |
| 143 |
Local Variables: |
| 144 |
mode: indented-text |
| 145 |
indent-tabs-mode: nil |
| 146 |
sentence-end-double-space: t |
| 147 |
fill-column: 70 |
| 148 |
coding: utf-8 |
| 149 |
End: |