[問題] Djangobook上的一段話 看不懂哩

看板Python作者 (881 forever)時間9年前 (2016/10/15 09:56), 9年前編輯推噓2(205)
留言7則, 1人參與, 最新討論串1/2 (看更多)
各位大大 在djangobook上有一段說明為啥要data model的地方看不太懂 有人可以幫忙解說一下嗎? 這裏的introspection是指? 感謝 http://djangobook.com/django-models/ Introspection requires overhead and is imperfect. In order to provide convenient data-access APIs, Django needs to know the database layout somehow, and there are two ways of accomplishing this. The first way would be to explicitly describe the data in Python, and the second way would be to introspect the database at runtime to determine the data models.This second way seems cleaner, because the metadata about your tables lives in only one place, but it introduces a few problems. First, introspecting a database at runtime obviously requires overhead. If the framework had to introspect the database each time it processed a request, or even only when the Web server was initialized, this would incur an unacceptable level of overhead. (While some believe that level of overhead is acceptable, Django’s developers aim to trim as much framework overhead as possible.) Second, some databases, notably older versions of MySQL, do not store sufficient metadata for accurate and complete introspection. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.226.168.84 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1476496575.A.7BB.html ※ 編輯: left (36.226.168.84), 10/15/2016 09:57:46

10/16 12:55, , 1F
introspection我不知道中文翻什麼,不過這個就像是
10/16 12:55, 1F

10/16 12:55, , 2F
JAVA的REFLECTION
10/16 12:55, 2F

10/16 13:04, , 3F
抱歉,我重看了一次,這理的introspection不非是py
10/16 13:04, 3F

10/16 13:04, , 4F
thon裡的introspection,這裡純綷指的是去讀databa
10/16 13:04, 4F

10/16 13:04, , 5F
se的schema,這樣作的話就可以動態取得資料型別,
10/16 13:04, 5F

10/16 13:04, , 6F
但會造成無法接受的overhead,也就是方便性和overh
10/16 13:04, 6F

10/16 13:04, , 7F
ead的tradeoff
10/16 13:04, 7F
文章代碼(AID): #1O0Oo_Ux (Python)
文章代碼(AID): #1O0Oo_Ux (Python)