作者left (881 forever)
看板Python
标题[问题] Djangobook上的一段话 看不懂哩
时间Sat Oct 15 09:56:10 2016
各位大大
在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://webptt.com/cn.aspx?n=bbs/Python/M.1476496575.A.7BB.html
※ 编辑: left (36.226.168.84), 10/15/2016 09:57:46
1F:推 IMPOSSIBLEr: introspection我不知道中文翻什麽,不过这个就像是 10/16 12:55
2F:→ IMPOSSIBLEr: JAVA的REFLECTION 10/16 12:55
3F:推 IMPOSSIBLEr: 抱歉,我重看了一次,这理的introspection不非是py 10/16 13:04
4F:→ IMPOSSIBLEr: thon里的introspection,这里纯綷指的是去读databa 10/16 13:04
5F:→ IMPOSSIBLEr: se的schema,这样作的话就可以动态取得资料型别, 10/16 13:04
6F:→ IMPOSSIBLEr: 但会造成无法接受的overhead,也就是方便性和overh 10/16 13:04
7F:→ IMPOSSIBLEr: ead的tradeoff 10/16 13:04