~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/plpython-python23.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>Python 2 vs. Python 3</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REV="MADE"
 
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
 
11
REL="HOME"
 
12
TITLE="PostgreSQL 9.1beta1 Documentation"
 
13
HREF="index.html"><LINK
 
14
REL="UP"
 
15
TITLE="PL/Python - Python Procedural Language"
 
16
HREF="plpython.html"><LINK
 
17
REL="PREVIOUS"
 
18
TITLE="PL/Python - Python Procedural Language"
 
19
HREF="plpython.html"><LINK
 
20
REL="NEXT"
 
21
TITLE="PL/Python Functions"
 
22
HREF="plpython-funcs.html"><LINK
 
23
REL="STYLESHEET"
 
24
TYPE="text/css"
 
25
HREF="stylesheet.css"><META
 
26
HTTP-EQUIV="Content-Type"
 
27
CONTENT="text/html; charset=ISO-8859-1"><META
 
28
NAME="creation"
 
29
CONTENT="2011-04-27T21:20:33"></HEAD
 
30
><BODY
 
31
CLASS="SECT1"
 
32
><DIV
 
33
CLASS="NAVHEADER"
 
34
><TABLE
 
35
SUMMARY="Header navigation table"
 
36
WIDTH="100%"
 
37
BORDER="0"
 
38
CELLPADDING="0"
 
39
CELLSPACING="0"
 
40
><TR
 
41
><TH
 
42
COLSPAN="5"
 
43
ALIGN="center"
 
44
VALIGN="bottom"
 
45
><A
 
46
HREF="index.html"
 
47
>PostgreSQL 9.1beta1 Documentation</A
 
48
></TH
 
49
></TR
 
50
><TR
 
51
><TD
 
52
WIDTH="10%"
 
53
ALIGN="left"
 
54
VALIGN="top"
 
55
><A
 
56
TITLE="PL/Python - Python Procedural Language"
 
57
HREF="plpython.html"
 
58
ACCESSKEY="P"
 
59
>Prev</A
 
60
></TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="left"
 
64
VALIGN="top"
 
65
><A
 
66
TITLE="PL/Python - Python Procedural Language"
 
67
HREF="plpython.html"
 
68
>Fast Backward</A
 
69
></TD
 
70
><TD
 
71
WIDTH="60%"
 
72
ALIGN="center"
 
73
VALIGN="bottom"
 
74
>Chapter 42. PL/Python - Python Procedural Language</TD
 
75
><TD
 
76
WIDTH="10%"
 
77
ALIGN="right"
 
78
VALIGN="top"
 
79
><A
 
80
TITLE="PL/Python - Python Procedural Language"
 
81
HREF="plpython.html"
 
82
>Fast Forward</A
 
83
></TD
 
84
><TD
 
85
WIDTH="10%"
 
86
ALIGN="right"
 
87
VALIGN="top"
 
88
><A
 
89
TITLE="PL/Python Functions"
 
90
HREF="plpython-funcs.html"
 
91
ACCESSKEY="N"
 
92
>Next</A
 
93
></TD
 
94
></TR
 
95
></TABLE
 
96
><HR
 
97
ALIGN="LEFT"
 
98
WIDTH="100%"></DIV
 
99
><DIV
 
100
CLASS="SECT1"
 
101
><H1
 
102
CLASS="SECT1"
 
103
><A
 
104
NAME="PLPYTHON-PYTHON23"
 
105
>42.1. Python 2 vs. Python 3</A
 
106
></H1
 
107
><P
 
108
>   PL/Python supports both the Python 2 and Python 3 language
 
109
   variants.  (The PostgreSQL installation instructions might contain
 
110
   more precise information about the exact supported minor versions
 
111
   of Python.)  Because the Python 2 and Python 3 language variants
 
112
   are incompatible in some important aspects, the following naming
 
113
   and transitioning scheme is used by PL/Python to avoid mixing them:
 
114
 
 
115
   <P
 
116
></P
 
117
></P><UL
 
118
><LI
 
119
><P
 
120
>      The PostgreSQL language named <TT
 
121
CLASS="LITERAL"
 
122
>plpython2u</TT
 
123
>
 
124
      implements PL/Python based on the Python 2 language variant.
 
125
     </P
 
126
></LI
 
127
><LI
 
128
><P
 
129
>      The PostgreSQL language named <TT
 
130
CLASS="LITERAL"
 
131
>plpython3u</TT
 
132
>
 
133
      implements PL/Python based on the Python 3 language variant.
 
134
     </P
 
135
></LI
 
136
><LI
 
137
><P
 
138
>      The language named <TT
 
139
CLASS="LITERAL"
 
140
>plpythonu</TT
 
141
> implements
 
142
      PL/Python based on the default Python language variant, which is
 
143
      currently Python 2.  (This default is independent of what any
 
144
      local Python installations might consider to be
 
145
      their <SPAN
 
146
CLASS="QUOTE"
 
147
>"default"</SPAN
 
148
>, for example,
 
149
      what <TT
 
150
CLASS="FILENAME"
 
151
>/usr/bin/python</TT
 
152
> might be.)  The
 
153
      default will probably be changed to Python 3 in a distant future
 
154
      release of PostgreSQL, depending on the progress of the
 
155
      migration to Python 3 in the Python community.
 
156
     </P
 
157
></LI
 
158
></UL
 
159
><P>
 
160
 
 
161
   It depends on the build configuration or the installed packages
 
162
   whether PL/Python for Python 2 or Python 3 or both are available.
 
163
  </P
 
164
><DIV
 
165
CLASS="TIP"
 
166
><BLOCKQUOTE
 
167
CLASS="TIP"
 
168
><P
 
169
><B
 
170
>Tip: </B
 
171
>    The built variant depends on which Python version was found during
 
172
    the installation or which version was explicitly set using
 
173
    the <TT
 
174
CLASS="ENVAR"
 
175
>PYTHON</TT
 
176
> environment variable;
 
177
    see <A
 
178
HREF="install-procedure.html"
 
179
>Section 15.4</A
 
180
>.  To make both variants of
 
181
    PL/Python available in one installation, the source tree has to be
 
182
    configured and built twice.
 
183
   </P
 
184
></BLOCKQUOTE
 
185
></DIV
 
186
><P
 
187
>   This results in the following usage and migration strategy:
 
188
 
 
189
   <P
 
190
></P
 
191
></P><UL
 
192
><LI
 
193
><P
 
194
>      Existing users and users who are currently not interested in
 
195
      Python 3 use the language name <TT
 
196
CLASS="LITERAL"
 
197
>plpythonu</TT
 
198
> and
 
199
      don't have to change anything for the foreseeable future.  It is
 
200
      recommended to gradually <SPAN
 
201
CLASS="QUOTE"
 
202
>"future-proof"</SPAN
 
203
> the code
 
204
      via migration to Python 2.6/2.7 to simplify the eventual
 
205
      migration to Python 3.
 
206
     </P
 
207
><P
 
208
>      In practice, many PL/Python functions will migrate to Python 3
 
209
      with few or no changes.
 
210
     </P
 
211
></LI
 
212
><LI
 
213
><P
 
214
>      Users who know that they have heavily Python 2 dependent code
 
215
      and don't plan to ever change it can make use of
 
216
      the <TT
 
217
CLASS="LITERAL"
 
218
>plpython2u</TT
 
219
> language name.  This will
 
220
      continue to work into the very distant future, until Python 2
 
221
      support might be completely dropped by PostgreSQL.
 
222
     </P
 
223
></LI
 
224
><LI
 
225
><P
 
226
>      Users who want to dive into Python 3 can use
 
227
      the <TT
 
228
CLASS="LITERAL"
 
229
>plpython3u</TT
 
230
> language name, which will keep
 
231
      working forever by today's standards.  In the distant future,
 
232
      when Python 3 might become the default, they might like to
 
233
      remove the <SPAN
 
234
CLASS="QUOTE"
 
235
>"3"</SPAN
 
236
> for aesthetic reasons.
 
237
     </P
 
238
></LI
 
239
><LI
 
240
><P
 
241
>      Daredevils, who want to build a Python-3-only operating system
 
242
      environment, can change the contents of
 
243
      <A
 
244
HREF="catalog-pg-pltemplate.html"
 
245
><TT
 
246
CLASS="STRUCTNAME"
 
247
>pg_pltemplate</TT
 
248
></A
 
249
>
 
250
      to make <TT
 
251
CLASS="LITERAL"
 
252
>plpythonu</TT
 
253
> be equivalent
 
254
      to <TT
 
255
CLASS="LITERAL"
 
256
>plpython3u</TT
 
257
>, keeping in mind that this
 
258
      would make their installation incompatible with most of the rest
 
259
      of the world.
 
260
     </P
 
261
></LI
 
262
></UL
 
263
><P>
 
264
  </P
 
265
><P
 
266
>   See also the
 
267
   document <A
 
268
HREF="http://docs.python.org/py3k/whatsnew/3.0.html"
 
269
TARGET="_top"
 
270
>What's
 
271
   New In Python 3.0</A
 
272
> for more information about porting to
 
273
   Python 3.
 
274
  </P
 
275
><P
 
276
>   It is not allowed to use PL/Python based on Python 2 and PL/Python
 
277
   based on Python 3 in the same session, because the symbols in the
 
278
   dynamic modules would clash, which could result in crashes of the
 
279
   PostgreSQL server process.  There is a check that prevents mixing
 
280
   Python major versions in a session, which will abort the session if
 
281
   a mismatch is detected.  It is possible, however, to use both
 
282
   PL/Python variants in the same database, from separate sessions.
 
283
  </P
 
284
></DIV
 
285
><DIV
 
286
CLASS="NAVFOOTER"
 
287
><HR
 
288
ALIGN="LEFT"
 
289
WIDTH="100%"><TABLE
 
290
SUMMARY="Footer navigation table"
 
291
WIDTH="100%"
 
292
BORDER="0"
 
293
CELLPADDING="0"
 
294
CELLSPACING="0"
 
295
><TR
 
296
><TD
 
297
WIDTH="33%"
 
298
ALIGN="left"
 
299
VALIGN="top"
 
300
><A
 
301
HREF="plpython.html"
 
302
ACCESSKEY="P"
 
303
>Prev</A
 
304
></TD
 
305
><TD
 
306
WIDTH="34%"
 
307
ALIGN="center"
 
308
VALIGN="top"
 
309
><A
 
310
HREF="index.html"
 
311
ACCESSKEY="H"
 
312
>Home</A
 
313
></TD
 
314
><TD
 
315
WIDTH="33%"
 
316
ALIGN="right"
 
317
VALIGN="top"
 
318
><A
 
319
HREF="plpython-funcs.html"
 
320
ACCESSKEY="N"
 
321
>Next</A
 
322
></TD
 
323
></TR
 
324
><TR
 
325
><TD
 
326
WIDTH="33%"
 
327
ALIGN="left"
 
328
VALIGN="top"
 
329
>PL/Python - Python Procedural Language</TD
 
330
><TD
 
331
WIDTH="34%"
 
332
ALIGN="center"
 
333
VALIGN="top"
 
334
><A
 
335
HREF="plpython.html"
 
336
ACCESSKEY="U"
 
337
>Up</A
 
338
></TD
 
339
><TD
 
340
WIDTH="33%"
 
341
ALIGN="right"
 
342
VALIGN="top"
 
343
>PL/Python Functions</TD
 
344
></TR
 
345
></TABLE
 
346
></DIV
 
347
></BODY
 
348
></HTML
 
349
>
 
 
b'\\ No newline at end of file'