Skip to content

py: Implement very simple frozen modules support. - #1074

Closed
pfalcon wants to merge 1 commit into
micropython:masterfrom
pfalcon:frozen-modules
Closed

pfalcon wants to merge 1 commit into
micropython:masterfrom
pfalcon:frozen-modules

Conversation

@pfalcon

@pfalcon pfalcon commented Jan 18, 2015

Copy link
Copy Markdown
Contributor

Only modules (not packages) supported now. Source modules can be converted
to frozen module structures using tools/make-frozen.py script.

@pfalcon

pfalcon commented Jan 18, 2015

Copy link
Copy Markdown
Contributor Author

Well, noone wants to implement it, so let's do it in small steps...

Comment thread py/builtinimport.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this doing a proper tail call? Important to keep stack usage down for imports, since they already use a lot of stack.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's pretty tail-recursive, and I confirmed that when compiled with optimization on x64, the function ends with jump to do_load_from_lexer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified it's a jump on stmhal. And with frozen modules not enabled, it just expands do_load_from_lexer in place here.

Only modules (not packages) supported now. Source modules can be converted
to frozen module structures using tools/make-frozen.py script.
@dpgeorge

Copy link
Copy Markdown
Member

Ok. Feel free to merge.

@dpgeorge

Copy link
Copy Markdown
Member

Rebased and merged by @pfalcon in 640e0b2.

@dpgeorge dpgeorge closed this Jan 20, 2015
Comment thread py/builtinimport.c Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it always safe to use MP_OBJ_QSTR_VALUE here instead of mp_obj_str_get_qstr? Just asking because I got bitten by it myself, see #1077

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. On line 227 the qstr is extracted from module_name using mp_obj_str_get_qstr, so should probably cache that return value and use it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wel, my general assumption that module name is identifier and thus always qstr, but thinking that it can be called as __import__, yes, need to do that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8064892

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants