Skip to content

Commit e30edfc

Browse files
committed
Remove py_import:import_stats/0
1 parent bd55baf commit e30edfc

2 files changed

Lines changed: 2 additions & 53 deletions

File tree

src/py_import.erl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
is_imported/2,
4444
all_imports/0,
4545
clear_imports/0,
46-
import_stats/0,
4746
import_list/0,
4847
%% Path registry
4948
add_path/1,
@@ -229,24 +228,6 @@ clear_imports() ->
229228
end,
230229
ok.
231230

232-
%% @doc Get import registry statistics.
233-
%%
234-
%% Returns a map with the count of registered imports.
235-
%%
236-
%% Example:
237-
%% ```
238-
%% {ok, #{count => 5}} = py_import:import_stats().
239-
%% '''
240-
%%
241-
%% @returns {ok, Stats} where Stats is a map with registry metrics
242-
-spec import_stats() -> {ok, map()} | {error, term()}.
243-
import_stats() ->
244-
Count = case ets:info(?IMPORT_REGISTRY) of
245-
undefined -> 0;
246-
_ -> ets:info(?IMPORT_REGISTRY, size)
247-
end,
248-
{ok, #{count => Count}}.
249-
250231
%% @doc List all registered imports.
251232
%%
252233
%% Returns a map of modules to their registered functions.

test/py_import_SUITE.erl

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import_nonexistent_module_test/1,
2323
import_nonexistent_function_test/1,
2424
import_idempotent_test/1,
25-
import_stats_test/1,
2625
import_list_test/1,
2726
import_speeds_up_calls_test/1,
2827
import_multiprocess_test/1,
@@ -55,7 +54,6 @@ groups() ->
5554
import_nonexistent_module_test,
5655
import_nonexistent_function_test,
5756
import_idempotent_test,
58-
import_stats_test,
5957
import_list_test,
6058
import_speeds_up_calls_test,
6159
import_multiprocess_test,
@@ -186,34 +184,6 @@ import_idempotent_test(_Config) ->
186184
%% Still works
187185
{ok, _} = py:call(json, dumps, [[1]]).
188186

189-
%% @doc Test import stats
190-
import_stats_test(_Config) ->
191-
%% Start fresh
192-
ok = py_import:clear_imports(),
193-
194-
%% Check empty stats
195-
{ok, Stats0} = py_import:import_stats(),
196-
?assertEqual(0, maps:get(count, Stats0, 0)),
197-
198-
%% Import some modules
199-
ok = py_import:ensure_imported(json),
200-
ok = py_import:ensure_imported(math),
201-
ok = py_import:ensure_imported(os),
202-
203-
%% Check stats
204-
{ok, Stats1} = py_import:import_stats(),
205-
Count1 = maps:get(count, Stats1, 0),
206-
?assertEqual(3, Count1),
207-
208-
%% Import functions
209-
ok = py_import:ensure_imported(json, dumps),
210-
ok = py_import:ensure_imported(json, loads),
211-
212-
%% Check updated stats (3 modules + 2 functions = 5)
213-
{ok, Stats2} = py_import:import_stats(),
214-
Count2 = maps:get(count, Stats2, 0),
215-
?assertEqual(5, Count2).
216-
217187
%% @doc Test listing imports
218188
import_list_test(_Config) ->
219189
%% Start fresh
@@ -323,11 +293,10 @@ import_multiprocess_test(_Config) ->
323293
?assertEqual([done, done, done], Results),
324294

325295
%% Now verify the GLOBAL registry has all entries
326-
{ok, Stats} = py_import:import_stats(),
327296
{ok, List} = py_import:import_list(),
328297

329298
%% Total entries: json, json.dumps, math, math.sqrt, math.floor, os, os.getcwd, string = 8
330-
?assertEqual(8, maps:get(count, Stats)),
299+
?assertEqual(8, length(py_import:all_imports())),
331300

332301
%% Verify all modules are in the shared registry
333302
?assert(maps:is_key(<<"json">>, List)),
@@ -383,8 +352,7 @@ import_concurrent_stress_test(_Config) ->
383352
end, Results),
384353

385354
%% Verify the global registry has all modules
386-
{ok, Stats} = py_import:import_stats(),
387-
Count = maps:get(count, Stats),
355+
Count = length(py_import:all_imports()),
388356
%% Should have all 10 modules (some may have been imported multiple times but ETS dedupes)
389357
?assertEqual(10, Count),
390358

0 commit comments

Comments
 (0)