Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions conference_notes/pycon_2015_links.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ I attended the two tutorials on Scikit-Learn, the one on Pyspark, and the one on

I prepared my own Vagrantfiles for use with Pyspark and Kivy, and shared them with the instructors.

* The Pyspark Vagrantfile turned out to work perfectly, and it was a real education to construct. My sense is that Pyspark may be useful if one absolutely has to use Spark within Python, but for many purposes where parallelism is not required, Scikit-Learn or Pandas would be better tools. Pyspark is kind of clunky.
* The Pyspark Vagrantfile turned out to work perfectly, and it was a real education to construct. My sense is that Pyspark may be useful if one absolutely has to use Spark within Python, but for many purposes where parallelism is not required, Scikit-Learn or Pandas would be better tools. Pyspark is kind of clunky and unPythonic.
* The Kivy Vagrantfile worked correctly until I realized that it would not be easy to display the graphical output, since X11-forwarding is hard to get working with VirtualBox and X11/Quartz on OS X. Kivy, in addition, seems to require so many dependencies, and their relationships are so brittle, that I think it would be hard to develop for it regularly. Though, of course, if one uses it regularly, configuring the environment probably becomes second-nature.

---
Expand Down Expand Up @@ -50,10 +50,10 @@ I took detailed notes only on the four tutorials, but I think the content in the
### Python education and best practices

* [Amy Hanlon — Investigating Python Wats](https://www.youtube.com/watch?v=sH4XF6pKKmk)
* [Stuart Williams - Python Epiphanies](https://www.youtube.com/watch?v=Ug0iDjbMPVg)
* [Stuart Williams Python Epiphanies](https://www.youtube.com/watch?v=Ug0iDjbMPVg) (tutorial)
* [Stuart Williams — Python by Immersion](https://www.youtube.com/watch?v=RVNIdoepdzU) (tutorial)
* [Raymond Hettinger — Beyond PEP 8: Best practices for beautiful intelligible code](https://www.youtube.com/watch?v=wf-BqAjZb8M)
* [Ned Batchelder — Facts and Myths about Python names and values](https://www.youtube.com/watch?v=_AEJHKGk9ns)
* [Ned Batchelder — Facts and Myths about Python names and values](https://www.youtube.com/watch?v=_AEJHKGk9ns): "Names have no value; values have no scope."

### Self-development for coders

Expand All @@ -62,16 +62,16 @@ I took detailed notes only on the four tutorials, but I think the content in the

### Python internals

* [Allison Kaptur - Bytes in the Machine: Inside the CPython interpreter](https://www.youtube.com/watch?v=HVUTjQzESeo)
* [Carol Willing - Finding Your Groove: Contributing to CPython and Beyond](https://www.youtube.com/watch?v=szeo1XgmuEk)
* [Allison Kaptur Bytes in the Machine: Inside the CPython interpreter](https://www.youtube.com/watch?v=HVUTjQzESeo)
* [Carol Willing Finding Your Groove: Contributing to CPython and Beyond](https://www.youtube.com/watch?v=szeo1XgmuEk)
* [Philip James, Asheesh Laroia — Type python, press enter. What happens?](https://www.youtube.com/watch?v=XVhSjZYwZJo)

## Inspiring Pythonist speakers

* [Brandon Rhodes — Oh, Come On Who Needs Bytearrays](https://www.youtube.com/watch?v=z9Hmys8ojno)
* [David Beazley — Modules and Packages: Live and Let Die!](https://www.youtube.com/watch?v=0oTh1CXRaQ0)
* [David Beazley — Modules and Packages: Live and Let Die!](https://www.youtube.com/watch?v=0oTh1CXRaQ0) (tutorial)
* [David Beazley — Python Concurrency From the Ground Up: LIVE!](https://www.youtube.com/watch?v=MCs5OvhV9S4)
* [Raymond Hettinger — Super considered super!](https://www.youtube.com/watch?v=EiOglTERPEo)
* [Raymond Hettinger — Super considered super!](https://www.youtube.com/watch?v=EiOglTERPEo): "Dependency injection."

### Other miscellaneous topics of interest

Expand All @@ -87,4 +87,4 @@ I took detailed notes only on the four tutorials, but I think the content in the
* [Michael Scherer — Ansible beyond YAML](https://www.youtube.com/watch?v=igJTEugHozM)
* [Richard Jones — Introduction to game programming with Kivy](https://www.youtube.com/watch?v=U14P8gtjQmU)

[end]
[end]
17 changes: 17 additions & 0 deletions python_class_at_mm/classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def raise_to_power(x, n):
"""Raise x to power n and return."""
return x ** n

class PowerTool(object):
"""Model behaviors related to raising a number to a power."""
def __init__(self, x):
self.x = x

def raise_me(self, n):
"""Return value of x raised to power n; don't change x."""
return self.x ** n

def replace_with_power(self, n):
"""Replace x with x raised to power n; don't return it."""
self.x **= n

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Joining strings by simple concatenation rather than the `+` operator

Below I use `timeit` to compare the speed of joining strings by two different methods. First, comparatively short strings.

```bash
$ python -m timeit "_ = ('aaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaa')"
10000000 loops, best of 3: 0.0214 usec per loop
$ python -m timeit "_ = ('aaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaa')"
10000000 loops, best of 3: 0.0819 usec per loop
$ python -c "print(0.0819 / 0.0214)"
3.827102803738318
```

Using the `+` operator increases running time by a factor of almost 4.

Now with longer strings and more of them:

```bash
$ python -m timeit "_ = ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"
10000000 loops, best of 3: 0.022 usec per loop
$ python -m timeit "_ = ('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"
1000000 loops, best of 3: 0.748 usec per loop
$ python -c "print(0.748 / 0.022)"
34.0
```

Using the `+` operator increases running time by a factor of 34.

[end]