Show More
@@ -2023,21 +2023,21 class InteractiveShell(SingletonConfigurable): | |||
|
2023 | 2023 | if next_input: |
|
2024 | 2024 | self.set_next_input(next_input) |
|
2025 | 2025 | |
|
2026 | magic_name, _, magic_args = arg_s.partition(' ') | |
|
2026 | magic_name, _, magic_arg_s = arg_s.partition(' ') | |
|
2027 | 2027 | magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) |
|
2028 | 2028 | |
|
2029 | 2029 | fn = self.find_magic(magic_name) |
|
2030 | 2030 | if fn is None: |
|
2031 | 2031 | error("Magic function `%s` not found." % magic_name) |
|
2032 | 2032 | else: |
|
2033 | magic_args = self.var_expand(magic_args, 1) | |
|
2033 | magic_arg_s = self.var_expand(magic_arg_s, 1) | |
|
2034 | # Put magic args in a list so we can call with f(*a) syntax | |
|
2035 | args = [magic_arg_s] | |
|
2034 | 2036 | # Grab local namespace if we need it: |
|
2035 | 2037 | if getattr(fn, "needs_local_scope", False): |
|
2036 |
s |
|
|
2038 | args.append(sys._getframe(1).f_locals) | |
|
2037 | 2039 | with self.builtin_trap: |
|
2038 |
result = fn( |
|
|
2039 | # Ensure we're not keeping object references around: | |
|
2040 | self._magic_locals = {} | |
|
2040 | result = fn(*args) | |
|
2041 | 2041 | return result |
|
2042 | 2042 | |
|
2043 | 2043 | def define_magic(self, magic_name, func): |
@@ -2017,7 +2017,7 Currently the magic system has the following functions:\n""" | |||
|
2017 | 2017 | |
|
2018 | 2018 | @skip_doctest |
|
2019 | 2019 | @needs_local_scope |
|
2020 |
def magic_time(self,parameter_s |
|
|
2020 | def magic_time(self,parameter_s, user_locals): | |
|
2021 | 2021 | """Time execution of a Python statement or expression. |
|
2022 | 2022 | |
|
2023 | 2023 | The CPU and wall clock times are printed, and the value of the |
@@ -2084,19 +2084,17 Currently the magic system has the following functions:\n""" | |||
|
2084 | 2084 | tc = clock()-t0 |
|
2085 | 2085 | # skew measurement as little as possible |
|
2086 | 2086 | glob = self.shell.user_ns |
|
2087 | locs = self._magic_locals | |
|
2088 | clk = clock2 | |
|
2089 | 2087 | wtime = time.time |
|
2090 | 2088 | # time execution |
|
2091 | 2089 | wall_st = wtime() |
|
2092 | 2090 | if mode=='eval': |
|
2093 | st = clk() | |
|
2094 | out = eval(code, glob, locs) | |
|
2095 | end = clk() | |
|
2091 | st = clock2() | |
|
2092 | out = eval(code, glob, user_locals) | |
|
2093 | end = clock2() | |
|
2096 | 2094 | else: |
|
2097 | st = clk() | |
|
2098 | exec code in glob, locs | |
|
2099 | end = clk() | |
|
2095 | st = clock2() | |
|
2096 | exec code in glob, user_locals | |
|
2097 | end = clock2() | |
|
2100 | 2098 | out = None |
|
2101 | 2099 | wall_end = wtime() |
|
2102 | 2100 | # Compute actual times and report |
General Comments 0
You need to be logged in to leave comments.
Login now