[Commits] python.it commit r250 - python/contrib/faq/trunk

commit a svn.python.it commit a svn.python.it
Dom 31 Dic 2006 19:37:58 CET


Author: eriol
Date: Sun Dec 31 19:37:51 2006
New Revision: 250

Modified:
   python/contrib/faq/trunk/programming.ht
Log:
Tradotto blocco 2

Modified: python/contrib/faq/trunk/programming.ht
==============================================================================
--- python/contrib/faq/trunk/programming.ht	(original)
+++ python/contrib/faq/trunk/programming.ht	Sun Dec 31 19:37:51 2006
@@ -18,7 +18,7 @@
 **Traduzione Italiana**
 
 Questo documento, di pubblico dominio, è stato tradotto da 
-`Daniele Tricoli <mailto:eriol a huine.org?subject=Traduzione Programming FAQ>`_ 
+`Daniele Tricoli <mailto:eriol a mornie.org?subject=Traduzione Programming FAQ>`_
 (revisionato da 
 `Meo Bogliolo <mailto:meo a bogliolo.name?subject=Traduzione Programming FAQ>`_ 
 ): potete contattarli per qualsiasi
@@ -115,106 +115,113 @@
 standard di Python oltre che nella directory sorgente (per i moduli
 build-in). Successivamente trasforma
 .. [- MARK -] BEGIN PART 002 of 18
-the bytecode for modules written in Python into C code (array
-initializers that can be turned into code objects using the marshal
-module) and creates a custom-made config file that only contains those
-built-in modules which are actually used in the program.  It then
-compiles the generated C code and links it with the rest of the Python
-interpreter to form a self-contained binary which acts exactly like
-your script.
-
-Obviously, freeze requires a C compiler.  There are several other
-utilities which don't. The first is Gordon McMillan's installer at
+il bytecode dei moduli scritti in Python in codice C (array
+iniziallizzarori che possono essere tradotti in oggetti codice
+utilizzando il modulo marshal) e crea un file di configurazione
+personalizzato che contiene esclusivamente i moduli built-in che
+sono attualmente usati nel programma. Successivamente il codice C
+generato viene compilato e viene eseguito il link con il resto
+dell'interprete Python in modo da formare un binario auto-contenuto
+che si comporta esattamente come il vostro script.
+
+Ovviamente freeze ha bisogno di un compilatore C. Esistono diversi
+altri tool che non richiedono tale dipendenza. Il primo è l'installer
+di Gordon McMillan disponibile al seguente indirizzo
 
     http://www.mcmillan-inc.com/install1.html
 
-which works on Windows, Linux and at least some forms of Unix.
+che funziona su Windows, Linux e alcune varianti Unix.
 
-Another is Thomas Heller's py2exe (Windows only) at
+Un altro è py2exe di Thomas Heller (esclusivamente per Windows) presso
 
     http://starship.python.net/crew/theller/py2exe
 
-A third is Christian Tismer's `SQFREEZE
-<http://starship.python.net/crew/pirx>`_ which appends the byte code
-to a specially-prepared Python interpreter that can find the byte
-code in the executable.  It's possible that a similar approach will 
-be added to Python 2.4, due out some time in 2004.
-
-Other tools include Fredrik Lundh's `Squeeze
-<http://www.pythonware.com/products/python/squeeze>`_ and Anthony
-Tuininga's `cx_Freeze
-<http://starship.python.net/crew/atuining/cx_Freeze/index.html>`_.
-
+Un terzo è `SQFREEZE <http://starship.python.net/crew/pirx>`_ di
+Christian Tismer che accoda il bytecode ad un interprete Python
+appositamente preparato in modo da poter trovare il bytecode
+all'interno dell'eseguibile. È possibile che un simile approccio
+venga aggiunto a Python 2.4, asseso per il 2004.
+
+Vi sono, inoltre, `Squeeze
+<http://www.pythonware.com/products/python/squeeze>`_ di Fredrik
+Lundh e `cx_Freeze
+<http://starship.python.net/crew/atuining/cx_Freeze/index.html>`_
+di Anthony Tuininga.
 
-Are there coding standards or a style guide for Python programs?
+Esistono delle convenzioni di codifica o una guida sullo stile per i
+programmi in Python?
 ------------------------------------------------------------------------
-Yes.  The coding style required for standard library modules
-is documented as `PEP 8 <../../peps/pep-0008.html>`_.
+Si. Le convenzioni di codifica richieste per i moduli della libreria
+standard sono documentate nel `PEP 8 <../../peps/pep-0008.html>`_.
 
-My program is too slow. How do I speed it up?
+Il mio programma è troppo lento. Come velocizzarlo?
 ----------------------------------------------------
+In generale è una cosa difficile. Esistono molti trucchi per velocizzare
+codice Python; si consideri la riscrittura di parti di codice in C come
+ultima risorsa.
+
+In alcuni casi è possibile tradurre automaticamente Python in C o in
+assembly x86, senza la necessità di modificare il codice per ottenere
+un aumento di velocità.
+
+`Pyrex <http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/>`_ può
+compilare una versione leggermente modificata di codice Python in
+un'estensione in C, e può essere utilizzato in differenti piattaforme.
+
+`Psyco <http://psyco.sourceforge.net>`_ è un just-in-time compiler
+che traduce codice Python in assemply x86. Se è possibile utilizzarlo,
+Psyco può fornire un drammatico incremento di velocità per le funzioni
+critiche.
+
+Il resto di questa risposta discuterà vari trucchi per ottenere un 
+ulteriore incremento di velocità dal codice Python. Non bisogna *mai*
+utilizzare trucchi per l'ottimizzazione finchè non si è sicuri di
+averne bisogno, dopo che, ad esempio, il profiling ha indicato che
+una particolare funzione viene pesantemente eseguita nel vostro codice.
+L'ottimizzazione quasi sempre rende il codice meno chiaro, e non si
+dovrebbe pagare il prezzo di una leggibilità minore (aumento del tempo
+di sviluppo e maggiore probabilità di bug) a meno che l'incremento di
+performance non valga la pena.
 
-That's a tough one, in general.  There are many tricks to speed up
-Python code; consider rewriting parts in C as a last resort.  
-
-In some cases it's possible to automatically translate Python to C or
-x86 assembly language, meaning that you don't have to modify your code
-to gain increased speed.  
-
-`Pyrex <http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/>`_ can
-compile a slightly modified version of Python code into a C extension,
-and can be used on many different platforms.  
-
-`Psyco <http://psyco.sourceforge.net>`_ is a just-in-time compiler
-that translates Python code into x86 assembly language.  If you can
-use it, Psyco can provide dramatic speedups for critical functions.
-
-The rest of this answer will discuss various tricks for squeezing a
-bit more speed out of Python code.  *Never* apply any optimization
-tricks unless you know you need them, after profiling has indicated
-that a particular function is the heavily executed hot spot in the
-code.  Optimizations almost always make the code less clear, and you
-shouldn't pay the costs of reduced clarity (increased development
-time, greater likelihood of bugs) unless the resulting performance
-benefit is worth it.
-
-There is a page on the wiki devoted to `performance tips <http://wiki.python.org/moin/PythonSpeed/PerformanceTips>`_.
+Vi è una pagina del wiki dedicata ai `consigli sulle performance <http://wiki.python.org/moin/PythonSpeed/PerformanceTips>`_.
 
-Guido van Rossum has written up an anecdote related to optimization at
+Guido van Rossum ha scritto un aneddoto relativo all'ottimizzazione:
 http://www.python.org/doc/essays/list2str.html.
 
-One thing to notice is that function and (especially) method calls are
-rather expensive; if you have designed a purely OO interface with lots
-of tiny functions that don't do much more than get or set an instance
-variable or call another method, you might consider using a more
-direct way such as directly accessing instance variables.  Also see the
-standard module "profile" (`described in the Library Reference manual
-<http://docs.python.org/lib/module-profile.html>`_) which
-makes it possible to find out where your program is spending most of
-its time (if you have some patience -- the profiling itself can slow
-your program down by an order of magnitude).
-
-Remember that many standard optimization heuristics you
-may know from other programming experience may well apply
-to Python.  For example it may be faster to send output to output
-devices using larger writes rather than smaller ones in order to
-reduce the overhead of kernel system calls.  Thus CGI scripts
-that write all output in "one shot" may be faster than
-those that write lots of small pieces of output.
-
-Also, be sure to use Python's core features where appropriate.
-For example,  slicing allows programs to chop up
-lists and other sequence objects in a single tick of the interpreter's
-mainloop using highly optimized C implementations.  Thus to 
-get the same effect as::
+Una cosa da notare è che le chiamate a funzione e (specialmente) metodi
+sono piuttosto costose; se si è disegnata una pura interfaccia OO (n.d.t.
+orientata ad oggetti) con molte piccole funzioni che non fanno altro
+che ottenere o impostare una variabile d'istanza oppure chiamare un
+altro metodo, si può prendere in considerazione un approccio più diretto
+quale accedere direttamente alle variabili d'istanza.
+Si visioni il modulo standard "profile" (`descritto nel Library Reference
+manual <http://docs.python.org/lib/module-profile.html>`_) che rende
+possibile determinare dove il vostro programma stia impiegando la maggior
+parte del suo tempo (avendo un po' di pazienza -- il profiling stesso può
+rallentare il vostro programma di un ordine di grandezza).
+
+Ricordate che molte delle tecniche euristiche standard di ottimizzazione 
+che potreste conoscere grazie ad altre esperienze di programmazione
+possono essere ben applicate a Python. Per esempio può esser più veloce
+inviare l'output ai dispositivi di output utilizzando scritture più grandi
+piuttosto che più piccole in modo da ridurre l'overhead delle chiamate di
+sistema del kernel. Pertanto script CGI che scrivono l'output un "una volta"
+possono essere piò veloci di quelli che effettuano tante scritture di
+piccole parti di output.
+
+Inoltre, ricordate di utilizzare le caratteristiche base di Python dov'è
+opportuno.
+Per esempio lo slicing permette di tagliare liste ed altri oggetti sequenza
+in un singolo tick del mainloop dell'interprete utilizzando un'implementazione
+in C altamente ottimizzata. Perciò per ottenere lo stesso risultato di::
 
   L2 = []
   for i in range[3]:
        L2.append(L1[i])
 
-it is much shorter and far faster to use ::
+è più breve e veloce l'utilizzo di ::
 
-  L2 = list(L1[:3]) # "list" is redundant if L1 is a list.
+  L2 = list(L1[:3]) # "list" è ridondante se L1 è una lista.
 .. [- MARK -] BEGIN PART 003 of 18
 
 Note that the functionally-oriented builtins such as 


Maggiori informazioni sulla lista Commits