---
title: "用 Pickle 寫程式是否搞錯了什麼? - splitline"
tags: PyConTW2023, 2023-organize, 2023-共筆
---
# 用 Pickle 寫程式是否搞錯了什麼? - splitline
{%hackmd H6-2BguNT8iE7ZUrnoG1Tg %}
<iframe src=https://app.sli.do/event/kop39z2q71itU9VASt8zEZ height=450 width=100%></iframe>
> Collaborative writing start from below
> 從這裡開始共筆
## When we use Pickle?
但我們其實不在乎何時用到,因為我們只是想用pickle來寫程式(????????)
- Django/Flask caching
- Pre-trained Model
- Inter-Process Communication
[Pickora](https://github.com/splitline/Pickora)
## 如何把serial格式變成programming
```python
class SomeClass():
def __reduce__(self):
return (eval, "print('hi')", )
```
## what can pickle opcode do?
* Values: Create string, number, tuple, list, ...
* Call function: (without keyword arguments)
* Import something: `from x import y`
* Set attribute: `obj.attr = 1337`
* Set item: `obj[ ‘key’] = 1337`
* Other: `(pickle internal operation)`
## Function Call
- print("hi")
- c builtins \n print \n
- ( **V** *print* \n, **V** *hi* \n)
Below is the part that speaker updated the talk/tutorial after speech
講者於演講後有更新或勘誤投影片的部份