11.07.2015 Views

versión color - PET: Python Entre Todos - Python Argentina

versión color - PET: Python Entre Todos - Python Argentina

versión color - PET: Python Entre Todos - Python Argentina

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Guppy tips 89problemas.<strong>Todos</strong> queremos saber cómo evitar estos problemas, así que:Guppy tips• No dejar basura por el piso• Si se van a crear muchos objetos pequeños, crear los persistentesprimero, y los transientes al final.• Compilar código (ej: usar eval o hacer imports) genera cadenaspermanentes, llamadas cadenas internadas, así que compilaron-demand también es algo a evitar.• SQLAlchemy y muchas otras bibliotecas tienen cachés internos,investigar y estar al tanto de estas políticas.• Siempre que sea posible, preferir pocos objetos grandes a muchos objetospequeños:• Listas de strings → strings separados por comas. O pipes. O enter. Olo que sea.• Listas de números → array.array o numpy.array• Barrer de vez en cuando• Si se mantienen caches con expiración, limpiar el caché regularmentepara quitar elementos expirados• A veces se puede “desfragmentar” la memoria, reconstruyendoestructuras persistentes como los cachésDe hecho, el garbage collector de java hace esto automáticamente, ymuchos proyectos buscan implementar un garbage collector similar para<strong>Python</strong>, pero la API de extensión de <strong>Python</strong>, la <strong>Python</strong>/C, lo hace difícil alpermitir punteros directos a los PyObject, estructuras que representan losobjetos en <strong>Python</strong>)*.• El cambio es bueno• No crear estructuras eternas.• Los caches siempre expiran.• Los threads se renuevan.{footer} — http://revista.python.org.ar

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!