Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

c - Python memory model for this program

My query is on the below program with respect to symbols that are storing values and functions, when ran on http://pythontutor.com/.

memory model

My question is:

  1. How does python execution model look for above program on memory before start interpreting the python program? How do i visualise that memory layout? for example c executable has code/stack/heap/extra/data segments, just as an example, am not comparing

  2. Is 'const' a name of 32/64 bit memory area storing the value 2 with type assigned as integer?

  3. add()/sub()/other functions are shown in Objects column as per the diagram, So, How do i perceive functions being stored as Objects? How do i visualise it?

  4. As per the diagram, Is op a function pointer pointing to function sub()?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  1. Dictionaries on dictionaries. Dictionaries are the number 1 most important structure in Python.

  2. It is the key of an entry in the current scope's dictionary. The value is the object 2.

  3. It is not that functions are objects, but that some objects are functions. Or numbers. Or dictionaries.

  4. It is the key of an entry in the current scope's dictionary. The value is sub.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...