@@ -25,7 +25,7 @@ public Object(dynamic item, string name = null)
2525 }
2626
2727 [ InterpolatedStringHandler ]
28- public struct InterpolationHandler
28+ public struct CodeInterpolator
2929 {
3030 [ ThreadStatic ]
3131 private static StringBuilder _StringBuilder ;
@@ -54,7 +54,7 @@ StringBuilder CreateStringBuilder()
5454 public bool ShouldCompile ;
5555
5656 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
57- public InterpolationHandler ( int literalLength , int formattedCount )
57+ public CodeInterpolator ( int literalLength , int formattedCount )
5858 {
5959 var stringBuilder = LocalStringBuilder = STRING_BUILDER ;
6060 stringBuilder . Clear ( ) ;
@@ -63,9 +63,6 @@ public InterpolationHandler(int literalLength, int formattedCount)
6363 Scope = Py . CreateScope ( ) ;
6464
6565 ShouldCompile = true ;
66-
67- // var scope = Py.CreateScope();
68- // scope.Set()
6966 }
7067
7168 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
@@ -107,7 +104,7 @@ public void AppendFormatted(string text)
107104
108105 LocalStringBuilder . Append ( text ) ;
109106 }
110-
107+
111108 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
112109 public void AppendFormatted < T > ( T item )
113110 {
@@ -121,7 +118,7 @@ public void AppendFormatted(dynamic item, string format)
121118 }
122119
123120 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
124- public void AppendFormatted < T > ( dynamic item , string format )
121+ public void AppendFormatted < T > ( T item , string format )
125122 {
126123 if ( format == "py" )
127124 {
@@ -150,19 +147,20 @@ public enum CompilationOption
150147
151148 private static readonly ConcurrentDictionary < string , PyObject > CODE_TO_COMPILATION_MAP = new ConcurrentDictionary < string , PyObject > ( ) ;
152149
153- public static void Run ( InterpolationHandler code , CompilationOption compilationOption = CompilationOption . Auto )
150+ public static void Run ( CodeInterpolator code , CompilationOption compilationOption = CompilationOption . Auto )
154151 {
155152 var codeText = code . ToString ( ) ;
156153 using var scope = code . Scope ;
157154 RunInternal ( codeText , code , compilationOption ) ;
158155 }
159156
160- public static RetT Run < RetT > ( InterpolationHandler code , CompilationOption compilationOption = CompilationOption . Auto )
157+ public static RetT Run < RetT > ( CodeInterpolator code , CompilationOption compilationOption = CompilationOption . Auto )
161158 {
162159 var codeText = code . ToString ( ) ;
163160
164161 const string METHOD_WRAPPER_NAME = "py_wrapper_method" , RET_VAR_NAME = "py_ret" ;
165162
163+ // TODO: Somehow optimize performance of this
166164 codeText =
167165 $ """
168166 def { METHOD_WRAPPER_NAME } ():
@@ -177,7 +175,7 @@ public static RetT Run<RetT>(InterpolationHandler code, CompilationOption compil
177175 return scope . Get < RetT > ( RET_VAR_NAME ) ;
178176 }
179177
180- private static void RunInternal ( string codeText , InterpolationHandler code , CompilationOption compilationOption )
178+ private static void RunInternal ( string codeText , CodeInterpolator code , CompilationOption compilationOption )
181179 {
182180 var scope = code . Scope ;
183181
0 commit comments