-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
419 lines (357 loc) · 11.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>reveal.js</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/monokai.css">
<style>
.turn {
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
.code_data_comparison_wrapper {
width: 100%;
overflow: hidden;
}
.code_data_comparison {
font-size: 0.5em;
float: left;
width:50%
font-size: 15px;line-height : 15px;
}
.centered-content {
text-align: center;
}
.code_data {
font-size: 15px;
line-height : 15px;
}
.reveal .slides {
text-align: left;
}
.reveal .slides section>* {
margin-left: 0;
margin-right: 0;
}
</style>
<!-- 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>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>Python Features 3.5 > </h2>
<p>Novedades del lenguaje desde la versión 3.5 hasta 3.8</p>
</section>
<section>
<h4 class="centered-content">Jose Alberto Torres</h4>
<p class="centered-content"><img style="border:0;vertical-align:middle;background-color: #191919" height="42" width="42" data-src="slides/twitter.png"> @jata1984</p>
<p class="centered-content"><img style="border:0;vertical-align:middle;background-color: #191919" height="42" width="42" data-src="slides/github.png"> @jata84</p>
</section>
<section>
<section>
<h4 style="text-align: center;">Soporte para versiones de python</h4>
<img style="margin-left: 25%;" height="500" data-src="slides/images/history.png"></img>
</section>
</section>
<section>
<section>
<h4>Python 3.5</h4>
<p>PEP 492: Corutinas y sintaxis async await</p>
<p>PEP 484: Typehints
<p>PEP 498: Formatted string literals</p>
</section>
<section>
<h4>PEP 492: Corutinas y sintaxis async await</h4>
<div class="fragment">
<p>Declaración de corutinas con async</p>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:50%" class="fragment">
<p>Antes</p>
<pre><code data-trim data-noescape>
@asyncio.coroutine
def read_data(db):
pass
</code></pre>
</div>
<div style="float: left; width:50%" class="fragment">
<p>Ahora</p>
<pre><code data-trim data-noescape>
async def read_data(db):
pass
</code></pre>
</div>
</div>
</div>
<div class="fragment">
<p>Gestores de contexto asincronos:</p>
<pre><code data-trim data-noescape>
async with session.transaction():
await session.update(data)
</code></pre>
<code>
</code>
</div>
</section>
<section>
<p>PEP 484: Typehints</p>
<p class="fragment" >Tipo Callables</p>
<div class="fragment"><pre><code data-trim data-noescape>
from typing import Callable
def feeder(get_next_item: Callable[[], str]) -> None:
pass
</code></pre>
<p >Determina que el tipo función </p>
<p >Permite determinar los tipos de los argumentos de la función y sus respuestas</p>
</div>
</section>
<section>
<p>PEP 484: Typehints</p>
<p class="fragment" >Tipo Any</p>
<div class="fragment"><pre><code data-trim data-noescape>
from typing import Mapping
def use_map(m: Mapping[Any,Any]) -> None:
pass
</code></pre>
<p>El type Checker permitirá cualquier operación sobre ese valor</p>
</div>
</section>
<section>
<p>PEP 484: Typehints</p>
<p class="fragment" >Tipo Union</p>
<div class="fragment"><pre><code data-trim data-noescape>
from typing import Union
def handle_employees(e: Union[Employee, Sequence[Employee]]) -> None:
if isinstance(e, Employee):
e = [e]
</code></pre>
<p >Permitirá cualquiera de los dos valores introducidos dentro de la unión</p>
</div>
</section>
<section>
<p>PEP 498: Literal String Interpolation</p>
<div class="fragment">
<p>F-strings, formato de cadenas simple</p>
</div>
<div style="width: 100% ;overflow: hidden;">
<div class="fragment">
<p>Antes</p>
<pre><code data-trim data-noescape>
name="jose"
age=35
"mi nombre es {} y mi edad {}".format(name,age)
</code></pre>
</div>
<div class="fragment">
<p>Ahora</p>
<pre><code data-trim data-noescape>
name="jose"
age=35
f'mi nombre es {name} y mi edad {35}'
</code></pre>
</div>
</div>
</section>
</section>
<section>
<section>
<h4>Python 3.6</h4>
<p>PEP 515: Underscores in Numeric Literals</p>
<p>PEP 526: Syntax for Variable Annotations</p>
</section>
<section>
<h4>Python 3.6</h4>
<p>PEP 515: Underscores in Numeric Literals</p>
<div class="fragment">
<pre><code data-trim data-noescape>
# grouping decimal numbers by thousands
amount = 10_000_000.0
# grouping hexadecimal addresses by words
addr = 0xCAFE_F00D
# grouping bits into nibbles in a binary literal
flags = 0b_0011_1111_0100_1110
# same, for string conversions
flags = int('0b_1111_0000', 2)
</code></pre>
</div>
</section>
<section>
<h4>Python 3.6</h4>
<p>PEP 526: Syntax for Variable Annotations</p>
<div class="fragment">
<pre><code data-trim data-noescape>
python_version : float = 3.6
infectados_coronavirus : int = 100
</code></pre>
</div>
</section>
</section>
<section>
<section>
<h4>Python 3.7</h4>
<p>PEP 553: Built-in breakpoint()</p>
<p>PEP 567: Context Variable</p>
<p>PEP 557: Data Classes</p>
</section>
<section>
<h4>Python 3.7</h4>
<p>PEP 553: Built-in breakpoint()</p>
<img class="fragment" style="margin-left: 25%;" height="500" data-src="slides/images/hard_debugger.jpeg"></img>
</section>
<section>
<h4>Python 3.7</h4>
<p>PEP 553: Built-in breakpoint()</p>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:50%" class="fragment">
<p>Antes</p>
<pre><code style="font-size: 15px;line-height : 15px;" data-trim data-noescape>
import pdb
pdb.set_trace()
</code></pre>
</div>
<div style="float: left; width:50%" class="fragment">
<p>Ahora</p>
<pre><code style="font-size: 15px;line-height : 15px;" data-trim data-noescape>
breakpoint()
</code></pre>
</div>
</div>
<p class="fragment">En python tenemos los debugger: pdb, ipdb,pudb pdbpp</p>
<p class="fragment">Se puede configurar con variables de entorno</p>
</section>
<section>
<h4>Python 3.7</h4>
<p>PEP 567: Context Variable</p>
<p class="fragment">Al pertenecer al mismo hilo es necesario un mecanismo de almacenamiento de variables</p>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:100%" class="fragment">
<pre><code style="font-size: 15px;line-height : 15px;" data-trim data-noescape>
import contextvars
current_user = contextvars.ContextVar('current_user',default=None)
async def inner():
log.debug('Current user: %s',current_user.get())
@routes.get('/{name}')
async def handler(request):
current_user.set(request.match_info["name"])
await inner()
</code></pre>
</div></div>
</section>
<section>
<h4>Python 3.7</h4>
<p>PEP 557: Data Classes</p>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:100%" class="fragment">
<pre><code style="font-size: 15px;line-height : 15px;" data-trim data-noescape>
class Point(object)
def __init__(self, x:float,y:float,z:float=0):
self.x = x
self.y = y
self.z = z
</code></pre>
</div></div>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:100%" class="fragment">
<pre><code style="font-size: 15px;line-height : 15px;" data-trim data-noescape>
@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False)
class Point:
x: float
y: float
z: float = 0.0
p = Point(1.5, 2.5)
print(p) # produces "Point(x=1.5, y=2.5, z=0.0)"
</code></pre>
</div></div>
</section>
</section>
<section>
<section>
<h4>Python 3.8</h4>
<p>PEP 572: Assignment Expressions</p>
<p>PEP 570: Positional Arguments</p>
</section>
<section>
<h4>Python 3.7</h4>
<p>PEP 572: Assignment Expressions (walrus operator)</p>
<p class="centered-content" style="font-size:80px">:=</p>
<img class="fragment centered_content turn" height="200" data-src="slides/images/walrus-turn.jpeg"></img>
</section>
<section>
<h4>Python 3.8</h4>
<p>PEP 572: Assignment Expressions (walrus operator)</p>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:50%" class="fragment">
<p>Antes</p>
<pre><code data-trim data-noescape>
match = pattern.search(data)
if match:
# Do something with match
</code></pre>
</div>
<div style="float: left; width:50%" class="fragment">
<p>Ahora</p>
<pre><code data-trim data-noescape>
if (match := pattern.search(data)) is not None:
# Do something with match
</code></pre>
</div>
</div>
</section>
<section>
<h4>Python 3.8</h4>
<p>PEP 570: Positional Arguments</p>
<div style="width: 100% ;overflow: hidden;">
<div style="float: left; width:100%" class="fragment">
<pre><code data-trim data-noescape>
def f(pos1,pos2,/,pos_or_kwd,*,kwd)
</code></pre>
</div>
<p class="fragment">Antes de la barra, son argumentos únicamente posicionales</p>
<p class="fragment">Despues de la barra son posicionales o kewords</p>
<p class="fragment">Despues del asterisco son kewords</p>
</div>
</section>
</section>
<section>
<section>
<h4 class="centered-content">Muchas Gracias!</h4>
<img class="fragment centered_content" height="500" data-src="slides/images/thanks.jpg"></img>
</section>
<section>
<h4 class="centered-content">¿¿Preguntas??</h4>
</section>
</section>
</div>
</div>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
hash: true,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/highlight/highlight.js' },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>