[TIL] python3 deep dive - part 1 (유데미)
역시 데이터 처리할 일이 있으니 파이썬이 필요합니다.
파이썬을 잘 안다고 생각했지만, 이번에 공부해 보니 모르는 것 투성이네요.
https://www.udemy.com/course/python-3-deep-dive-part-1/
제법 길지만 알찬 46시간 짜리 강의를 완주했습니다. (그러고도 part 2, 3, 4 가 남아있습니다.)
그런데 다른 파이썬 강의에서는 접하기 힘든 내용이 많아서 매우 유익합니다.
integer object 가 캐시된다는 걸 몰랐는데 재미있습니다.
(-5에서 256 까지의 정수만 미리 만들어져 있고, 코드 중에 해당 정수가 사용되면 해당 인스턴스가 쓰입니다.)
100 == 100 이지만 500≠500 이네요.
a = 100
b = 100
print(f"ID of a: {id(a)}")
print(f"ID of b: {id(b)}")
print(a is b)
# Output: True (They are the exact same object in memory)
c = 500
d = 500
print(f"ID of c: {id(c)}")
print(f"ID of d: {id(d)}")
print(c is d)
# Output: False (500 is outside the cached range, so two different objects are created)스트링은 컴파일시에 캐시를 만드는데, 코드에 존재하는 스트링 중에서 변수명으로 쓰일수 있는 형식의 스트링은 캐시됩니다.
(“Hello, World” 는 캐시되지 않고 “hello_world” 는 캐시됨)
unpacking 이 함수의 parameter 처리와 같은 기능이라는 것을 알게 되었습니다.
a, *b, (c, d, e) = [1, 2, 3, 'xyz']
print (a, b)
# Output : 1 [2, 3]function inspection 을 알게 됩니다
func.__name__
func.__defaults__
func.__kwdefaults__
func.__code__.co_varnames
func.__code__.co_argcounts
inspect.getcomments(my_func)
inspect.signature(my_func)lambda 와 reduce 에 대해 정리할 수 있었고, partial function 도 알게 되었습니다.
closure 와 decorator 를 제대로 이해하게 해 줍니다.
(관련해서 지식 게시판에 게시물을 올렸습니다. https://okky.kr/user/192307/articles/1547604 )
module 과 package, 그리고 import 의 사용법에 대해 제대로 이해하게 해 줍니다.
강력히 추천할 만합니다.
