User Tools

Site Tools


other:python:jyp_steps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
other:python:jyp_steps [2016/01/19 15:28]
jypeter created
other:python:jyp_steps [2016/01/20 10:58]
jypeter
Line 1: Line 1:
-====== Following JYP's steps ======+====== Following JYP'​s ​recommended ​steps ======
  
 As can be expected, there is **a lot** of online python documentation available, and it's easy to get lost. You can always use google to find an answer to your problem, and you will probably end up looking at lots of answers on [[http://​stackoverflow.com/​questions/​tagged/​python|Stack Overflow]] or a similar site. But it's always better to know where you can find some good documentation... and to spend some time to read the documentation As can be expected, there is **a lot** of online python documentation available, and it's easy to get lost. You can always use google to find an answer to your problem, and you will probably end up looking at lots of answers on [[http://​stackoverflow.com/​questions/​tagged/​python|Stack Overflow]] or a similar site. But it's always better to know where you can find some good documentation... and to spend some time to read the documentation
  
-This page tries to list some //python for the scientist// related resources, in a suggested reading order.+This page tries to list some //python for the scientist// related resources, in a suggested reading order. ​**Do not print anything** (or at least not everything),​ but it's a good idea to download all the //pdf// files in the same place, so that you can easily open and search the documents 
 + 
 +===== The official python documentation ===== 
 + 
 +You do not need to read all the python documentation at this step, but it is really well made and you should at least have a look at it. The **Tutorial** is really well made, and you should have a look at the table of content of the **Python Standard Library**. There is a lot in the default library that can make your life easier 
 + 
 +==== Python 2.7 ==== 
 + 
 +[[https://​docs.python.org/​2.7/​|html]] - [[https://​docs.python.org/​2.7/​download.html|pdf]] 
 + 
 +==== Python 3 ==== 
 + 
 +[[https://​docs.python.org/​3/​|html]] - [[https://​docs.python.org/​3/​download.html|pdf]] 
 + 
 +===== Scipy Lecture Notes ===== 
 + 
 +Summary: //One document to learn numerics, science, and data with Python// 
 + 
 +Where: [[http://​www.scipy-lectures.org/​_downloads/​ScipyLectures-simple.pdf|pdf]] - [[http://​www.scipy-lectures.org/​|html]] 
 + 
 +This is a really nice document that is regularly updated and used for the [[https://​www.euroscipy.org/​|EuroScipy]] tutorials
  
 ===== Quick Reference ===== ===== Quick Reference =====
  
-  * The nice Python 2.7 Quick Reference: [[http://​rgruet.free.fr/​PQR27/​PQR2.7_printing_a4.pdf|pdf]] ​and [[http://​rgruet.free.fr/​PQR27/​PQR2.7.html|html]]+  * The nice Python 2.7 Quick Reference: [[http://​rgruet.free.fr/​PQR27/​PQR2.7_printing_a4.pdf|pdf]] ​[[http://​rgruet.free.fr/​PQR27/​PQR2.7.html|html]]
  
 ===== Some good coding tips ===== ===== Some good coding tips =====
Line 14: Line 34:
  
   * [[http://​blog.codinghorror.com/​a-pragmatic-quick-reference/​|A Pragmatic Quick Reference]]   * [[http://​blog.codinghorror.com/​a-pragmatic-quick-reference/​|A Pragmatic Quick Reference]]
 +
 +===== Improving the performance of your code =====
 +
 +You can already get a very efficient script by checking the following:
 +
 +  * **make sure that your script is not using too much memory** (the amount depends on the computer you are using)! Your script should be scalable (e.g. keeps on working even when your data gets bigger), so it's a good idea to load only the data you need in memory (e.g. not all the time steps), and learn how to load chunks of data
 +
 +  * **make sure that you are using array/​vector syntax and masks**, instead of using explicit loops and tests. The numpy documentation is big, because there are lots of optimized functions to help you!
 +
 +If your script is still not fast enough, there is a lot you can do to improve it, without resorting to parallelization (that may introduce extra bugs rather that extra performance). See the sections below
 +
 +Hint: before optimizing your script, you should spent some time //​profiling//​ it, in order to only spend time improving the slow parts of your script
 +
 +==== Tutorials by Ian Osvald ====
 +
 +  * [[http://​ianozsvald.com/​2011/​07/​25/​|Tutorials from EuroScipy 2011]]
 +  * [[http://​ianozsvald.com/​2012/​03/​18/​|Tutorials from PyCon 2012]]
 +
 +===== Python 2.7 vs Python 3 =====
 +
 +The official [[https://​docs.python.org/​2.7/​howto/​pyporting.html|Porting Python 2 Code to Python 3]] page gives the required information to make the transition from python 2 to python 3. It is still safe to use Python 2.7, so there is no rush to change to Python 3.
  
 /* standard page footer */ /* standard page footer */
other/python/jyp_steps.txt · Last modified: 2024/03/07 10:15 by jypeter