optimize_code
Optimize code for large datasets by analyzing R, Stata, or Python scripts and suggesting performance improvements based on data size specifications.
Instructions
대용량 데이터용 코드 최적화 제안
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | 최적화할 코드 | |
| data_size | No | 데이터 크기 (행 수, GB) | |
| language | Yes | 언어 |
Implementation Reference
- src/tools/index.ts:452-463 (registration)Registration of the 'optimize_code' tool in the exported tools array, including name, description, and input schema definition.
name: "optimize_code", description: "대용량 데이터용 코드 최적화 제안", inputSchema: { type: "object", properties: { code: { type: "string", description: "최적화할 코드" }, data_size: { type: "string", description: "데이터 크기 (행 수, GB)" }, language: { type: "string", enum: ["r", "stata", "python"], description: "언어" }, }, required: ["code", "language"], }, }, - src/tools/index.ts:1699-1709 (handler)The implementation of the 'optimize_code' tool handler. It returns language-specific recommendations for optimizing code for large datasets, ignoring the provided code snippet.
function handleOptimizeCode(args: Record<string, unknown>) { return { language: args.language, data_size: args.data_size, recommendations: { r: ["Use data.table instead of data.frame", "Use fst for file I/O", "Consider collapse package"], stata: ["Use gtools (gisid, gegen)", "Use ftools (reghdfe)", "Compress data"], python: ["Use pandas with chunking", "Consider dask or polars", "Use parquet format"] } }; } - src/tools/index.ts:846-847 (registration)The switch case in the main handleToolCall function that routes calls to the 'optimize_code' handler.
case "optimize_code": return handleOptimizeCode(args);