@@ -288,8 +288,9 @@ $$ LANGUAGE plpythonu;
288
288
<sect2>
289
289
<title>Data Type Mapping</title>
290
290
<para>
291
- Function arguments are converted from their PostgreSQL type to a
292
- corresponding Python type:
291
+ When a PL/Python function is called, its arguments are converted from
292
+ their PostgreSQL data type to a corresponding Python type:
293
+
293
294
<itemizedlist>
294
295
<listitem>
295
296
<para>
@@ -322,7 +323,7 @@ $$ LANGUAGE plpythonu;
322
323
Otherwise,
323
324
<literal>decimal.Decimal</literal> from the standard library will be
324
325
used. <literal>cdecimal</literal> is significantly faster
325
- than <literal>decimal</literal>. In Python 3.3,
326
+ than <literal>decimal</literal>. In Python 3.3 and up ,
326
327
however, <literal>cdecimal</literal> has been integrated into the
327
328
standard library under the name <literal>decimal</literal>, so there is
328
329
no longer any difference.
@@ -356,8 +357,9 @@ $$ LANGUAGE plpythonu;
356
357
</para>
357
358
358
359
<para>
359
- Function return values are converted to the declared PostgreSQL
360
- return data type as follows:
360
+ When a PL/Python function returns, its return value is converted to the
361
+ function's declared PostgreSQL return data type as follows:
362
+
361
363
<itemizedlist>
362
364
<listitem>
363
365
<para>
@@ -373,16 +375,18 @@ $$ LANGUAGE plpythonu;
373
375
When the PostgreSQL return type is <type>bytea</type>, the
374
376
return value will be converted to a string (Python 2) or bytes
375
377
(Python 3) using the respective Python built-ins, with the
376
- result being converted <type>bytea</type>.
378
+ result being converted to <type>bytea</type>.
377
379
</para>
378
380
</listitem>
379
381
380
382
<listitem>
381
383
<para>
382
- For all other PostgreSQL return types, the returned Python
383
- value is converted to a string using the Python
384
- built-in <literal>str</literal>, and the result is passed to the
385
- input function of the PostgreSQL data type.
384
+ For all other PostgreSQL return types, the return value is converted
385
+ to a string using the Python built-in <literal>str</literal>, and the
386
+ result is passed to the input function of the PostgreSQL data type.
387
+ (If the Python value is a <type>float</>, it is converted using
388
+ the <literal>repr</> built-in instead of <literal>str</literal>, to
389
+ avoid loss of precision.)
386
390
</para>
387
391
388
392
<para>
0 commit comments