Skip to content

Commit ab99612

Browse files
author
hartsantler
committed
deprecated function extra introspective data, pythonjs.js now 20KB smaller.
1 parent 76e1a98 commit ab99612

2 files changed

Lines changed: 234 additions & 780 deletions

File tree

pythonjs/python_to_pythonjs.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ def __init__(self, source=None, module=None, module_path=None, dart=False, coffe
194194
self._generator_functions = set()
195195

196196
self._in_loop_with_else = False
197+
self._introspective_functions = False
197198

198199
self._custom_operators = {}
199200
self._injector = [] ## advanced meta-programming hacks
@@ -2904,20 +2905,21 @@ def visit_FunctionDef(self, node):
29042905

29052906

29062907
if not self._with_dart and not self._with_lua: ## Dart functions can not have extra attributes?
2907-
## note, in javascript function.name is a non-standard readonly attribute,
2908-
## the compiler creates anonymous functions with name set to an empty string.
2909-
writer.write('%s.NAME = "%s"' %(node.name,node.name))
2908+
if self._introspective_functions:
2909+
## note, in javascript function.name is a non-standard readonly attribute,
2910+
## the compiler creates anonymous functions with name set to an empty string.
2911+
writer.write('%s.NAME = "%s"' %(node.name,node.name))
29102912

2911-
writer.write( '%s.args_signature = [%s]' %(node.name, ','.join(['"%s"'%n.id for n in node.args.args])) )
2912-
defaults = ['%s:%s'%(self.visit(x[0]), self.visit(x[1])) for x in zip(node.args.args[-len(node.args.defaults):], node.args.defaults) ]
2913-
writer.write( '%s.kwargs_signature = {%s}' %(node.name, ','.join(defaults)) )
2914-
if self._with_fastdef or fastdef:
2915-
writer.write('%s.fastdef = True' %node.name)
2913+
writer.write( '%s.args_signature = [%s]' %(node.name, ','.join(['"%s"'%n.id for n in node.args.args])) )
2914+
defaults = ['%s:%s'%(self.visit(x[0]), self.visit(x[1])) for x in zip(node.args.args[-len(node.args.defaults):], node.args.defaults) ]
2915+
writer.write( '%s.kwargs_signature = {%s}' %(node.name, ','.join(defaults)) )
2916+
if self._with_fastdef or fastdef:
2917+
writer.write('%s.fastdef = True' %node.name)
29162918

2917-
writer.write( '%s.types_signature = {%s}' %(node.name, ','.join(types)) )
2919+
writer.write( '%s.types_signature = {%s}' %(node.name, ','.join(types)) )
29182920

2919-
if return_type:
2920-
writer.write('%s.return_type = "%s"'%(node.name, return_type))
2921+
if return_type:
2922+
writer.write('%s.return_type = "%s"'%(node.name, return_type))
29212923

29222924
if not self._with_js and not javascript:
29232925
writer.write('%s.pythonscript_function=True'%node.name)

0 commit comments

Comments
 (0)