<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">

        <title>Python 3.6 - Novidades da Versão</title>

        <meta name="description" content="A framework for easily creating beautiful presentations using HTML">
        <meta name="author" content="Hakim El Hattab">

        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">

        <link rel="stylesheet" href="reveal.js/css/reveal.css">
        <link rel="stylesheet" href="reveal.js/css/theme/black.css" id="theme">

        <!-- Code syntax highlighting -->
        <link rel="stylesheet" href="reveal.js/lib/css/zenburn.css">

        <!-- Printing and PDF exports -->
        <script>
            var link = document.createElement( 'link' );
            link.rel = 'stylesheet';
            link.type = 'text/css';
            link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
            document.getElementsByTagName( 'head' )[0].appendChild( link );
        </script>

        <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.js"></script>
        <![endif]-->

        <style type="text/css" media="screen">
            .happy {
                color: yellow;
            }

            .semi-opaque {
                background-color: rgba(0, 0, 0, 0.7);
            }

            .reveal section img {
                border: none;
            }

			ul.empty {
				list-style: none;
			}
        </style>
    </head>

    <body>
        <div class="reveal">
            <div class="slides">
                <section>
                    <section data-background='_images/python.jpg' data-header>
                        <div class="semi-opaque">
                            <h1>Python 3.6</h1>
                            <h2>Novidades da versão</h2>
                        </div>
                    </section>
                </section>

                <section>
                    <section>
                        <img src="_images/AYV1X0yv.png" alt="Me" style="float:left;height:200px;" class="no-border">

                        <div>
                            <ul class='empty'>
                                <li>Júlio Biason</li>
                                <li><img src="_images/logo-horizontal-claro.png" alt="CWI Software" class='no-border'>
                                <li>@juliobiason</li>
                                <li>julio.biason@gmail.com</li>
                                <li><a href="http://presentations.juliobiason.net">http://presentations.juliobiason.net</a></li>
                            </ul>
                        </div>
                    </section>
                </section>

				<section>
					<section>
						<img src="_images/python36-new.png" alt="A full screenshot of the changes in Python 3.6" height="300px"/>
					</section>

					<section>
						<img src="_images/london-ripper.jpg" alt="Vamos por partes"/>
					</section>

					<section>
						<img src="_images/neat.jpg" alt="Neat."/>
					</section>

					<section>
						<img src="_images/my_opinion.jpg" alt="My opinion"/>
					</section>
				</section>

                <section>
                    <section>
                        <h2>Underscores em números</h2>

                        <pre><code class="python">&gt;&gt;&gt; 1_000_000_000 == 1000000000
True</code></pre>

                        <pre class="fragment"><code class="python">&gt;&gt;&gt; 1_00_00_00_00_0</code></pre>

                        <pre class="fragment"><code class="python">&gt;&gt;&gt; '{:_}'.format(1000000)
'1_000_000'</code></pre>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>String literals</h2>

                        <pre><code class="python">&gt;&gt;&gt; name = 'Julio'
&gt;&gt;&gt; f'My name is {name}'
My name is Julio</code></pre>

                        <pre class="fragment"><code class="python">&gt;&gt;&gt; def f():
...     name = 'Julio'
...     print('My name is {name}'.format(**locals()))</code></pre>
                    </section>

                    <section>
                        <pre><code class="python">
all(list(print(f'{i} bottle{"s" if i != 1 else ""} of '
f'beer on the wall, {str(i).lower()} '
f'bottle{"s" if i != 1 else ""} of beer.\n{"Take one '
f'down pass it around" if str(i).lower() == str(i) '
f'else "Go to the store and buy some more"}, '
f'{i-1 if i not in [1, "No more"] else "no more" '
f'if i == 1 else 99} bottles of beer on the wall.\n') \
for i in list(range(99, 0, -1))+['No more'])) \
or ""
                        </code></pre>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>Type annotations</h2>

                        <p>Só pra lembrar...</p>

                        <pre><code class="python">&gt;&gt;&gt; def(name: str) -&gt; str:
...     return 'Hello ' + name</code></pre>

                        <p class="fragment">
                            Não signfica que o CPython valida o parâmetro ou o retorno.
                        </p>
                    </section>

                    <section>
                        <pre><code class="python">&gt;&gt;&gt; captain: str    # mas continua como undefined</code></pre>
                        <pre><code class="python">&gt;&gt;&gt; values: List[int] = [1, 2, 4]</code></pre>

                        <p class="fragment">Essas informações podem ser extraídas de <code>__annotations__</code>
                            (assim como docstrings podem ser extraídas de <code>__doc__</code>).</p>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>secrets</h2>

                        <p>Nova biblioteca para geração de números randômicos "fortes", utilizados 
                        para criptografia.</p>

                        <pre><code class="python">&gt;&gt;&gt; token_hex(16)  
'f9bf78b9a18ce6d46a0cd2b0b86df9da'</code></pre>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>enum</h2>

                        <p>Novo tipo <code>auto</code> para gerar número automaticamente.
                        </p>

						<pre><code class="python">&gt;&gt;&gt; from enum import Enum, auto
&gt;&gt;&gt; class Color(Enum):
...     red = auto()
...     blue = auto()
...     green = auto()
...
&gt;&gt;&gt; list(Color)
[<&lt;Color.red: 1>, &lt;Color.blue: 2>, &lt;Color.green: 3>]</code></pre>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>importlib</h2>

                        <p>Ao tentar importar um módulo que não existe, será gerado
                            <code>ModuleNotFoundError</code> ao invés de
                            <code>ImportError</code>.</p>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>Pathlib</h2>

                        <p>Representação de um caminho qualquer no sistema de arquivos.</p>

						<pre><code class="python">&gt;&gt;&gt; import pathlib
&gt;&gt;&gt; with open(pathlib.Path("README")) as f:
...     contents = f.read()
...      
&gt;&gt;&gt; import os.path
&gt;&gt;&gt; os.path.splitext(pat)
('some_file', '.txt')</code></pre>
                    </section>

                    <section>
                        <p>Nova função para tornar objetos Path-like: <code>__fspath()__</code></p>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>Novos "dicionários"</h2>

                        <p><code>dict</code> agora é mais compacto.</p>
                        <p class="fragment">Efeito colateral: agora são ordenados em CPython,
                        mas não no spec da linguagem Python.</p>
                    </section>

                    <section>
                        <ul>
                            <li><code>**kwargs</code> agora são ordenados.</li>
                            <li><code>__dict__</code> agora é ordenado.</li>
                        </ul>
                    </section>
                </section>

                <section>
                    <section>
                        <h2>Async the world!</h2>

						<p><code>asyncio</code> agora é oficial.</p>
                    </section>

					<section>
						<h3>Async generators</h3>

						<pre><code class="python">async def ticker(delay, to):
	"""Yield numbers from 0 to *to* every *delay* seconds."""
	for i in range(to):
		yield i
		await asyncio.sleep(delay)</code></pre>
					</section>

                    <section>
                        <h3>Async comprehensions</h3>

                        <pre><code class="python">result = [i async for i in aiter() if i % 2]</code></pre>

                        <pre><code class="python">result = [await fun() for fun in funcs if await condition()]</code></pre>
                    </section>
                </section>

				<section>
					<section>
						<h2>Last but not least</h2>

						<ul>
							<li>Customização de classes com <code>__init_subclass__()</code>;</li>
							<li>Suporte a DTrace e SystemTrap;</li>
							<li>Variável de ambiente para mudar a forma de alocação de memória e mudanças
								no módulo <code>tracemalloc</code>;</li>
							<li>Desambiguação de datas com entrada do horário de verão;</li>
							<li><code>typing</code> com novidades;</li>
						</ul>
					</section>

					<section>
						<ul>
							<li><code>os.urandom()</code> vai bloquear até que haja entropia suficiente
								para gerar um número;</li>
							<li>Suporte a OpenSSL 1.1.0;</li>
							<li>Novos métodos criptográficos em <code>hashlib</code>;</li>
							<li>Sistema de arquivos do Windows agora é considerado UTF-8;</li>
							<li>Facilidades para definir o PATH das bibliotecas com arquivos
							._pth.</li>
						</ul>
					</section>
				</section>
            </div>
        </div>

        <script src="reveal.js/lib/js/head.min.js"></script>
        <script src="reveal.js/js/reveal.js"></script>

        <script>
            // Full list of configuration options available at:
            // https://github.com/hakimel/reveal.js#configuration
            Reveal.initialize({
                controls: true,
                progress: true,
                history: true,
                center: true,
                // showNotes: true,

                transition: 'slide', // none/fade/slide/convex/concave/zoom

                // Optional reveal.js plugins
                dependencies: [
                    { src: 'reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
                    { src: 'reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
                    { src: 'reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
                    { src: 'reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
                    { src: 'reveal.js/plugin/zoom-js/zoom.js', async: true },
                    { src: 'reveal.js/plugin/notes/notes.js', async: true }
                ]
            });
        </script>

    </body>
</html>