[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-07-01 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:


New changeset 0d7f61ddb074659d8c18c8f5ac86a6a18e41f9e5 by Batuhan Taskaya in 
branch 'main':
bpo-44313: bump up magic (#26983)
https://github.com/python/cpython/commit/0d7f61ddb074659d8c18c8f5ac86a6a18e41f9e5


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-07-01 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +25545
pull_request: https://github.com/python/cpython/pull/26983

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-07-01 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-30 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 1b28187a0e3e914ee48de8032cbba0a965dd5563 by Batuhan Taskaya in 
branch 'main':
bpo-44313: generate LOAD_ATTR/CALL_FUNCTION for top-level imported objects 
(GH-26677)
https://github.com/python/cpython/commit/1b28187a0e3e914ee48de8032cbba0a965dd5563


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-11 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +25263
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/26677

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-10 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-10 Thread Mark Shannon


Mark Shannon  added the comment:

Yes. Simpler is good.


I think it will also be better for performance:

In general, we don't know what X is in `from Y import X`. It could be a module 
or anything else.

However, if we are accessing an attribute it is quite likely to be a module or 
class.
For `X` defined by `from Y import X`, `X` is likely to be a module, class, 
function, or some sort of constant like a string, int or Enum.

If it is a string, int or function then it is rare to call a method on it, so 
we can ignore that case.
Calling methods on an Enum constant is probably not very common either (I'm 
guessing here)

For a module, `LOAD_ATTR; CALL_FUNCTION` is clearly better than `LOAD_METHOD; 
CALL_METHOD`.

For a class, specializing `LOAD_ATTR` is no more complex than `LOAD_METHOD`, 
probably simpler.
So, for a class `LOAD_ATTR; CALL_FUNCTION` is no worse than `LOAD_METHOD; 
CALL_METHOD`, and might be better.


Overall, it looks like `X.foo()` when `X` is defiend by `from Y import X` is 
best as `LOAD_ATTR; CALL_FUNCTION` not `LOAD_METHOD; CALL_METHOD`.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-04 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

@mark.shannon what do you think about doing this both for `import ` and 
`from  import `. It will definitely simplify the 
implementation (no need to extra visitors or flags, just using the default 
DEF_IMPORT one 
https://github.com/isidentical/cpython/commit/f8f8fcee4d1480970c356eec0f23c326b9fe674d)
 and also might help you to specialize other cases too (e.g importing 
submodules, from concurrent import futures).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44313] Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for imports

2021-06-04 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

import foo
def func():
return foo.bar()

The snippet above will generate the following code;

  2   0 LOAD_GLOBAL  0 (foo)
  2 LOAD_METHOD  1 (bar)
  4 CALL_METHOD  0
  6 RETURN_VALUE

Though this will make things harder for specializing the LOAD_ATTR for modules 
since now the handling of LOAD_METHOD for that case is necessary so for the 
imports that we can infer during the symbol analysis pass, we'll generate 
LOAD_ATTR+CALL_ATTR instead of LOAD_METHOD+CALL_METHOD and hopefully the 
generated code will get specialized via the PEP 659.

Ref: https://github.com/faster-cpython/ideas/issues/55#issuecomment-853101039

--
assignee: BTaskaya
components: Interpreter Core
messages: 395099
nosy: BTaskaya, Mark.Shannon
priority: normal
severity: normal
status: open
title: Generate LOAD_ATTR+CALL_FUNCTION instead of LOAD_METHOD+CALL_METHOD for 
imports
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com