profiling and optimizing

Stefan Behnel stefan_ml at behnel.de
Tue Jul 31 08:22:23 EDT 2012


Rita, 31.07.2012 14:13:
> I recently inherented a large python process and everything is lovely. As a
> learning experience I would like to optimize the code so I ran it thru the
> profiler
> 
> python -m cProfile myscript.py
> 
> It seems majority of the time is taking in the deep copy but that seems to
> come from a function (or functions) in the code. Is there a way to optimize
> that? perhaps have a C implementation of the deep copy? Would that
> be feasible?

Those approaches would be my second (or maybe even later) step. The first
one would be to check if the deep copy is really necessary, and if so, if
it is really necessary to do it over the full depth of the entire object graph.

Stefan





More information about the Python-list mailing list