Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Beyond the pip
Search
Daniela
February 23, 2019
Technology
0
62
Beyond the pip
Making sense of the dependency jungle
Daniela
February 23, 2019
Tweet
Share
More Decks by Daniela
See All by Daniela
System for Continuous Health Monitoring
danielacraciun
0
46
ELK Stack
danielacraciun
0
98
DNS Tunneling
danielacraciun
0
92
Django ORM vs SqlAlchemy (an comparison)
danielacraciun
1
1.3k
Other Decks in Technology
See All in Technology
アジャイルな開発チームでテスト戦略の話は誰がする? / Who Talks About Test Strategy?
ak1210
1
830
目標と時間軸 〜ベイビーステップでケイパビリティを高めよう〜
kakehashi
PRO
8
1k
開発組織を進化させる!AWSで実践するチームトポロジー
iwamot
2
540
ExaDB-XSで利用されているExadata Exascaleについて
oracle4engineer
PRO
3
300
いまからでも遅くない!コンテナでWebアプリを動かしてみよう!コンテナハンズオン編
nomu
0
180
"TEAM"を導入したら最高のエンジニア"Team"を実現できた / Deploying "TEAM" and Building the Best Engineering "Team"
yuj1osm
1
240
Ruby on Railsで持続可能な開発を行うために取り組んでいること
am1157154
3
160
困難を「一般解」で解く
fujiwara3
7
2.2k
AI自体のOps 〜LLMアプリの運用、AWSサービスとOSSの使い分け〜
minorun365
PRO
9
1.1k
20250304_赤煉瓦倉庫_DeepSeek_Deep_Dive
hiouchiy
2
130
30→150人のエンジニア組織拡大に伴うアジャイル文化を醸成する役割と取り組みの変化
nagata03
0
350
データベースの負荷を紐解く/untangle-the-database-load
emiki
2
550
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
175
52k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Speed Design
sergeychernyshev
27
820
GraphQLの誤解/rethinking-graphql
sonatard
69
10k
KATA
mclloyd
29
14k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7.1k
Transcript
Beyond Beyond the pip the pip
Disclaimer: this is not about Disclaimer: this is not about
pip (in particular). pip (in particular).
None
[Introduction slide]
None
It's the year 2019 It's the year 2019 are we
supposed to write our are we supposed to write our own code now?? own code now??
NOPE. NOPE. BUT DOUBT. EVERYTHING. BUT DOUBT. EVERYTHING.
None
The good The good
The good The good Multitude of libraries
The good The good Multitude of libraries Ease of use
The good The good Multitude of libraries Ease of use
Open source software
The bad The bad
The bad The bad Poorly written & documented
The bad The bad Poorly written & documented Not optimized
The bad The bad Poorly written & documented Not optimized
Might go missing
The ugly The ugly
The ugly The ugly Security issues
The ugly The ugly Security issues Malicious activity (typosquatting happening)
The ugly The ugly Security issues Malicious activity (typosquatting happening)
Dependency hell
Review time! Review time!
Is the library... Is the library...
Is the library... Is the library... mature? mature?
Is the library... Is the library... mature? mature? used in
commercial products? used in commercial products?
Is the library... Is the library... mature? mature? used in
commercial products? used in commercial products? backed up by other organizations? backed up by other organizations?
Is the library... Is the library...
Is the library... Is the library... used all through your
project? used all through your project?
Is the library... Is the library... used all through your
project? used all through your project? heavily relying on other libraries? heavily relying on other libraries?
Improve the library Improve the library Contribute to open source!
Contribute to open source!
Use a pattern... Use a pattern... wrap it up! (the
code, that is) wrap it up! (the code, that is) from external_dependency import something class SomeExternalDependencyClient: def __init__(self, credentials, name): self.client = something.Client(credentials, name) def get_items(self, ids): self.client.get(ids) def send_items(self, item_list): self.client.batch_insert(item_list)
The standard library is The standard library is awesome! awesome!
Good resources Good resources Module of the Week by Doug Hellmann PyTricks by Dan Bader
You have You have ... ... magic methods magic methods
class Hasher(object): def __init__(self, algorithm): self.algorithm = algorithm def __call__(self, file): hash = self.algorithm() with open(file, 'rb') as f: for chunk in iter(lambda: f.read(4096), ''): hash.update(chunk) return hash.hexdigest() md5 = Hasher(hashlib.md5) sha1 = Hasher(hashlib.sha1) md5(somefile)
Awesome Awesome decorators decorators from functools import wraps def retry(count=5,
exc_type=Exception): def decorator(func): @wraps(func) def result(*args, **kwargs): last_exc = None for _ in range(count): try: return func(*args, **kwargs) except exc_type as e: last_exc = e raise last_exc return result return decorator @retry def might_fail(): # some code here pass
class Cache: def __init__(self): self.memo = {} def store(self, fn):
def wrapper(*args): if args not in self.memo: self.memo[args] = fn(*args) return self.memo[args] return wrapper def clear(self): self.memo.clear() cache = Cache() @cache.store def somefct(): return expensive_call() cache.clear()
Powerful Powerful containers containers >>> from collections import Counter >>>
colors = ['blue', 'red', 'blue', 'yellow', 'blue', 'red'] >>> counter = Counter(colors) Counter({'blue': 3, 'red': 2, 'yellow': 1}) >>> counter.most_common()[0][0] 'blue' >>> Point = collections.namedtuple('Point', 'x y') >>> p = Point(1, y=2) Point(x=1, y=2) >>> p.x 1 >>> getattr(p, 'y') 2 >>> p._fields ('x', 'y')
and so many MORE! and so many MORE! utilities utilities
powerful powerful speci c operations speci c operations dev tools: dev tools: , , , , date & time handling date & time handling regex regex os os pydoc pydoc unittest unittest pdb pdb
I still think libraries are cool, I still think libraries
are cool, okay? okay?
This is it. Thank you!