User Tools

Site Tools


python:python

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
python:python [2014/03/06 11:14] – [Python] dblumepython:python [2022/06/15 07:49] – Mention flask gunicorn nginx dblume
Line 1: Line 1:
-====== Python ======+====== General Python Notes ======
  
 Man, there's too much to do and note.  Logging some stuff to investigate later... Man, there's too much to do and note.  Logging some stuff to investigate later...
Line 7: Line 7:
   * [[http://pytools.codeplex.com/releases/view/76089|Python Tools for Visual Studio 2010]].   * [[http://pytools.codeplex.com/releases/view/76089|Python Tools for Visual Studio 2010]].
   * [[http://wiki.python.org/moin/PythonSpeed/PerformanceTips|Python Performance Tips at the Python wiki]].   * [[http://wiki.python.org/moin/PythonSpeed/PerformanceTips|Python Performance Tips at the Python wiki]].
-  * Of course, there's getting Python running under Xampp. [[xampp]]+  * Of course, there'[[:xampp|getting Python running under Xampp]].
   * There's [[http://www.infoworld.com/d/application-development/pillars-python-six-python-web-frameworks-compared-169442|A comparison of CubicWeb, Django, Pyramid, Web.py, Web2py, and Zope 2]]   * There's [[http://www.infoworld.com/d/application-development/pillars-python-six-python-web-frameworks-compared-169442|A comparison of CubicWeb, Django, Pyramid, Web.py, Web2py, and Zope 2]]
-  * Look into the microframework [[http://flask.pocoo.org/|Flask]]. Here's a [[http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world|tutorial on making a blog with it]].+  * Look into the microframework [[http://flask.pocoo.org/|Flask]]. Here's a [[http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world|tutorial on making a blog with it]]. Consider flask with gunicorn and nginx.
   * [[https://dataset.readthedocs.org/en/latest/|dataset]], an abstraction layer above relational databases.   * [[https://dataset.readthedocs.org/en/latest/|dataset]], an abstraction layer above relational databases.
   * [[http://docopt.org/|docopt]] for a stupidly easy and correct command-line interface description language.   * [[http://docopt.org/|docopt]] for a stupidly easy and correct command-line interface description language.
   * [[http://stevenloria.com/python-best-practice-patterns-by-vladimir-keleshev-notes/|Best practices]] by Vladimir Keleshev.   * [[http://stevenloria.com/python-best-practice-patterns-by-vladimir-keleshev-notes/|Best practices]] by Vladimir Keleshev.
 +  * [[https://twitter.com/brandon_rhodes/status/449938490516860928|You can ask a new-style class for its .__subclasses__()]] It uses weak references. Look at [[https://gist.github.com/etrepum/9862280|this interesting example with a child class inside a method]].
 +  * A Power Point deck by Alex Martelli describing [[http://www.aleax.it/yt_pydi.pdf|Dependency Injection vs. Template Method (override base method) vs. Monkey Patching]].
 +  * [[http://stackoverflow.com/questions/101268/hidden-features-of-python|Hidden Features of Python]] at StackOverflow
 +  * [[http://chriskiehl.com/article/parallelism-in-one-line|Parallelism in one line]]
  
 Would be nice to create a binary search in text files in Python.  Maybe based on an answer deep in [[http://stackoverflow.com/questions/744256/reading-huge-file-in-python|Reading Huge File in Python]]. Would be nice to create a binary search in text files in Python.  Maybe based on an answer deep in [[http://stackoverflow.com/questions/744256/reading-huge-file-in-python|Reading Huge File in Python]].
Line 245: Line 249:
     finally:     finally:
         fcntl.flock(f, fcntl.LOCK_UN)         fcntl.flock(f, fcntl.LOCK_UN)
 +</code>
 +
 +====== Various Approaches to threaded URL Requests ======
 +
 +  * [[https://stackoverflow.com/questions/2632520/what-is-the-fastest-way-to-send-100-000-http-requests-in-python|Use Queue and threading's Thread]]
 +  * [[https://www.shanelynn.ie/using-python-threading-for-multiple-results-queue/|Use threading and store results in a pre-allocated list]]. Then use Queue for lots of URLs.
 +  * [[https://dev.to/rhymes/how-to-make-python-code-concurrent-with-3-lines-of-code-2fpe|Use concurrent.futures' ThreadPoolExecutor and map()]].
 +  * Or, use the doc's [[https://docs.python.org/3/library/concurrent.futures.html#threadpoolexecutor-example|ThreadPoolExecutor Example]].
 +  * And, as mentioned in Parallelism in One Line, [[https://chriskiehl.com/article/parallelism-in-one-line|multiprocessing.dummy's Pool and its own map()]].
 +
 +====== Fibonacci Generator with Itertools ======
 +
 +<code python>
 +import itertools
 +
 +def fib(n):
 +    """Print a Fibonacci series up to n."""
 +    a, b = 0, 1
 +    while True:
 +        yield a
 +        b = a + b
 +        yield b
 +        a = a + b
 +
 +if __name__ == '__main__': 
 +    for x in itertools.islice(fib(), 5):
 +        print x
 +
 +#    for i in range( 5 ):
 +#        print i, fib( i )
 </code> </code>
  
python/python.txt · Last modified: 2024/02/27 15:43 by dblume