Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66792 > unrolled thread
| Started by | Sam <lightaiyee@gmail.com> |
|---|---|
| First post | 2014-02-20 22:37 -0800 |
| Last post | 2014-03-01 15:22 +1100 |
| Articles | 20 on this page of 217 — 27 participants |
Back to article view | Back to comp.lang.python
Can global variable be passed into Python function? Sam <lightaiyee@gmail.com> - 2014-02-20 22:37 -0800
Re: Can global variable be passed into Python function? dieter <dieter@handshake.de> - 2014-02-21 08:23 +0100
Re: Can global variable be passed into Python function? Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-21 10:55 +0200
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 12:10 +0200
Re: Can global variable be passed into Python function? Peter Otten <__peter__@web.de> - 2014-02-21 08:34 +0100
Re: Can global variable be passed into Python function? Gary Herron <gary.herron@islandtraining.com> - 2014-02-21 00:41 -0800
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-21 08:55 +0000
Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-21 07:13 -0500
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 14:52 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 03:28 +0000
Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-21 22:45 -0500
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 06:29 +0000
Re: Can global variable be passed into Python function? Travis Griggs <travisgriggs@gmail.com> - 2014-02-21 09:59 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 05:16 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-21 21:20 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 17:36 +1100
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 07:18 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 18:29 +1100
Re: Can global variable be passed into Python function? wxjmfauth@gmail.com - 2014-02-22 00:02 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 19:10 +1100
Re: Can global variable be passed into Python function? wxjmfauth@gmail.com - 2014-02-22 00:26 -0800
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 08:28 +0000
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 08:35 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 19:45 +1100
Re: Can global variable be passed into Python function? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-24 21:07 +1300
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-24 15:57 +0000
Re: Can global variable be passed into Python function? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-24 21:12 -0500
Re: Can global variable be passed into Python function? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-02-26 23:59 +1300
Re: Can global variable be passed into Python function? MRAB <python@mrabarnett.plus.com> - 2014-02-26 18:59 +0000
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 06:57 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-22 09:28 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-22 08:45 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-22 19:54 +1100
Python and variables (was: Can global variable be passed into Python function?) Ben Finney <ben+python@benfinney.id.au> - 2014-02-22 11:13 +1100
Re: Can global variable be passed into Python function? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-21 21:47 -0500
Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-21 22:14 -0500
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-22 14:15 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-22 16:44 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 01:39 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 12:50 +1100
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 06:20 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 18:23 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 11:52 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 10:30 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 21:32 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 13:01 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-23 22:12 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 17:24 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-24 02:41 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 23:04 +0200
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-23 21:18 +0000
Re: Can global variable be passed into Python function? Terry Reedy <tjreedy@udel.edu> - 2014-02-23 12:06 -0500
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-23 23:10 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-24 00:37 +0000
Re: Can global variable be passed into Python function? wxjmfauth@gmail.com - 2014-02-24 01:35 -0800
Re: Can global variable be passed into Python function? j.e.haque@gmail.com - 2014-02-24 10:05 -0800
Re: [OT] Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-02-24 11:19 -0700
Re: [OT] Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-24 19:42 +0000
Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-01 23:02 -0500
Re: [OT] Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-03-02 16:45 +0000
Re: [OT] Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 16:55 +0000
Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 06:24 +1100
Re: [OT] Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-03-03 14:18 +0000
Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-04 01:25 +1100
Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 15:17 +1100
Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-02 08:22 -0500
Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 00:57 +1100
Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-02 14:17 -0500
Re: [OT] Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 06:32 +1100
Re: [OT] Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-03-02 17:58 -0500
Re: Can global variable be passed into Python function? random832@fastmail.us - 2014-02-24 13:20 -0500
Re: [OT] Can global variable be passed into Python function? random832@fastmail.us - 2014-02-24 13:21 -0500
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-25 05:22 +1100
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-25 05:25 +1100
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-24 20:00 +0000
Re: Can global variable be passed into Python function? Dave Angel <davea@davea.name> - 2014-02-22 10:02 -0500
Re: Can global variable be passed into Python function? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-22 13:03 -0500
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-23 00:39 +0000
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-22 19:57 -0500
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 05:24 -0800
Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-27 12:54 -0500
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 15:29 -0800
Re: Can global variable be passed into Python function? Steven D'Aprano <steve@pearwood.info> - 2014-02-28 02:07 +0000
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 18:29 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 15:43 +1100
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-27 21:39 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 16:53 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 09:43 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve@pearwood.info> - 2014-02-28 08:23 +0000
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-02-28 19:46 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 12:02 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 21:55 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 13:30 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 22:51 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 14:25 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 00:22 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 22:08 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 13:38 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 23:22 +1100
Re: Can global variable be passed into Python function? Neil Cerutti <neilc@norwich.edu> - 2014-02-28 13:47 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 16:26 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 01:37 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 17:29 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 02:46 +1100
Re: Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-28 16:09 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 10:00 +0200
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 09:43 -0500
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 10:00 +0200
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 17:26 +0200
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-03-02 10:34 -0500
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 17:52 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 03:23 +1100
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 16:53 +0000
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-28 15:06 +0000
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 15:50 +0000
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 10:04 -0800
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 20:53 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 05:59 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 21:20 +0200
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 12:22 -0800
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-02-28 23:03 +0200
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-28 21:23 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 01:06 +0200
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 11:02 +1100
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 19:48 -0500
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 13:00 +1100
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 22:15 -0500
Re: Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-28 22:00 +0000
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 09:36 +1100
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 14:50 -0800
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 15:36 -0800
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 02:32 +0200
Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-28 19:40 -0500
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 17:08 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 13:01 +1100
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 21:30 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 17:24 +1100
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 13:40 -0800
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 22:01 +0000
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 14:07 -0800
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 23:21 +0000
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-03-01 16:23 -0800
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 11:28 +1100
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 00:36 +0000
Re: Can global variable be passed into Python function? Ned Deily <nad@acm.org> - 2014-03-01 16:55 -0800
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 01:15 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 09:11 +1100
Re: Can global variable be passed into Python function? Ned Batchelder <ned@nedbatchelder.com> - 2014-02-28 21:15 -0500
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 20:36 -0800
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 01:07 +0000
Re: Can global variable be passed into Python function? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-01 16:10 +1300
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-02-28 19:02 -0500
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 23:33 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 12:50 +1100
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-28 23:04 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 02:03 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 00:44 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 03:06 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 01:59 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 13:03 +1100
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 03:29 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 12:39 +0200
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 01:10 +0000
Re: Can global variable be passed into Python function? "Mark H. Harris" <harrismh777@gmail.com> - 2014-02-28 17:29 -0800
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 10:17 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 02:11 +0200
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 11:50 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 03:10 +0200
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 01:19 +0000
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 12:41 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 12:31 +0200
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 21:48 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 13:28 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-01 22:59 +1100
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 17:07 +0000
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 04:27 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 20:25 +0200
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 09:30 +1100
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 23:13 +0000
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 00:03 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 19:23 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 04:30 +1100
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 09:34 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 10:03 +0200
Re: Can global variable be passed into Python function? Ben Finney <ben+python@benfinney.id.au> - 2014-03-02 21:59 +1100
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 13:00 +0000
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-01 15:15 +0000
Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-01 10:05 -0700
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-01 19:29 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 04:36 +1100
Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-01 11:06 -0700
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-03-01 13:30 -0500
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-02 08:35 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 11:35 +0200
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 11:40 +0200
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-02 21:07 +1100
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 12:37 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-02 10:44 +0000
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 13:33 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-03 01:50 +0000
Re: Can global variable be passed into Python function? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-02 13:04 +0000
Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-02 11:48 -0700
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-02 23:03 +0200
Re: Can global variable be passed into Python function? Roy Smith <roy@panix.com> - 2014-03-02 16:16 -0500
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-03-03 08:28 +1100
Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-03-02 14:44 -0700
Re: Can global variable be passed into Python function? Marko Rauhamaa <marko@pacujo.net> - 2014-03-03 00:46 +0200
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 17:18 +0000
Re: Can global variable be passed into Python function? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-03-01 00:58 +0000
Re: Can global variable be passed into Python function? Michael Torrie <torriem@gmail.com> - 2014-02-28 07:49 -0700
Re: Can global variable be passed into Python function? Chris Angelico <rosuav@gmail.com> - 2014-02-28 20:00 +1100
Re: Can global variable be passed into Python function? Grant Edwards <invalid@invalid.invalid> - 2014-02-28 14:20 +0000
References, and avoiding use of “variable” (was: Can global variable be passed into Python function?) Ben Finney <ben+python@benfinney.id.au> - 2014-02-28 13:46 +1100
Re: References, and avoiding use of ???variable??? (was: Can global variable be passed into Python function?) Neil Cerutti <neilc@norwich.edu> - 2014-02-28 14:30 +0000
Re: References, and avoiding use of ???variable??? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 10:33 +1100
Re: References, and avoiding use of ???variable??? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-03-01 16:08 +1300
Re: References, and avoiding use of ???variable??? Ben Finney <ben+python@benfinney.id.au> - 2014-03-01 15:22 +1100
Page 3 of 11 — ← Prev page 1 2 [3] 4 5 … 11 Next page →
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-02-23 06:20 +0000 |
| Message-ID | <53099339$0$29985$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #66912 |
On Sun, 23 Feb 2014 12:50:26 +1100, Chris Angelico wrote:
> On Sun, Feb 23, 2014 at 12:39 PM, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> wrote:
>> In C or Pascal-style languages, what we might call the "fixed address"
>> style of variables, a variable assignment like xyz = 1 does something
>> like this:
>>
>> - associate the name 'xyz' with some fixed location
>> - stuff the value 1 into that location
>
> Kinda. In its purest sense, C is like that. When you declare "int xyz;",
> the compiler allocates one machine word of space either in the data
> segment (if that's at top level, or is declared static) or on the stack
> (if it's local), and records that the name xyz points there. But an
> optimizing C compiler is allowed to do what it likes, as long as it
> maintains that name binding... and as long as any recorded address of it
> remains valid.
I think that's a red herring. The semantics of the language are that it
behaves as if the variable had a fixed location. What goes on behind the
scenes is interesting but fundamentally irrelevant if you want to
understand the language itself: the compiler's implementation may give
that variable a fixed location, or not, or multiple locations, or non-
fixed, or whatever it finds useful at the time, so long as the C code you
write can assume that it is fixed. (That's like Python, which has no
pointers. The fact that the implementation of some Python interpreters
uses pointers all over the place is strictly irrelevant.)
In practice, because C compilers usually work so close to the metal, and
programmers expect there to be a very direct correspondence between the C
code you write and the machine code you get, the compiler is unlikely to
simulate fixed addresses unless there is real benefit to be gained, it is
more likely to actually use fixed addresses. But in principle, one might
write a C interpreter in Jython, and simulate fixed addresses over the
top of a language without any addresses at all (Python), which in turn is
written in a language where the garbage collector can move things around
(Java).
The important thing here is not so much that we are disagreeing, but that
we are talking about two different levels of explanation. ("Gödel, Escher
And Bach" has an very interesting section about how explanations at
different levels can be radically different and even contradict each
other.) At the C source code level, the language mandates that variables
have fixed addresses, to the extent that C source code knows about
addresses at all. At the generated machine code level, the compiler is
free to play tricks if necessary.
Another example: if you have a variable unused=23, and the compiler
removes it because it's dead code, we wouldn't argue that therefore C
variables have no existence at all. Would we? :-)
> So, these days, C is becoming more like Python.
*raises eyebrow*
I think the stress of the exception-expression PEP is getting to you.
They truly aren't.
*wink*
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-23 18:23 +1100 |
| Message-ID | <mailman.7275.1393140247.18130.python-list@python.org> |
| In reply to | #66919 |
On Sun, Feb 23, 2014 at 5:20 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> The important thing here is not so much that we are disagreeing, but that
> we are talking about two different levels of explanation. ("Gödel, Escher
> And Bach" has an very interesting section about how explanations at
> different levels can be radically different and even contradict each
> other.) At the C source code level, the language mandates that variables
> have fixed addresses, to the extent that C source code knows about
> addresses at all. At the generated machine code level, the compiler is
> free to play tricks if necessary.
I think that's a good summary, actually. C has variables, at the
source code level, but once you compile it down, it might not. From
which it follows that C variables have addresses (unless they're
declared 'register', in which case they might still be stored in RAM
but no longer have addresses), which may or may not have any actual
relationship to memory addresses.
> Another example: if you have a variable unused=23, and the compiler
> removes it because it's dead code, we wouldn't argue that therefore C
> variables have no existence at all. Would we? :-)
>
>> So, these days, C is becoming more like Python.
>
> *raises eyebrow*
>
> I think the stress of the exception-expression PEP is getting to you.
> They truly aren't.
>
> *wink*
Haha. I wasn't joking, though; a fully-optimizing compiler is free to
do so much that, in reality, you're not writing bare-metal code -
you're writing guidelines to a sophisticated program generator. C has
become as high level a language as any other, and has acquired some
Python-like features (check out some of the recent standards); and,
the part that I was talking about here, it makes the most sense to
talk about "name bindings" rather than memory addresses. Variables
might move around, but if you say "int xyz=5;", then you can be sure
that querying xyz will give you back 5. The concreteness of "declare a
variable ergo memory is allocated for it" is no longer the case.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-02-23 11:52 +0200 |
| Message-ID | <877g8mcg1m.fsf@elektro.pacujo.net> |
| In reply to | #66911 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info>: > The big difference is that in "fixed location" languages, it makes > sense to talk about the address of a *variable*. The address could be a symbol, too. The Python statement xyz = 3 places a number in the address "xyz". You can read the value from the address "xyz" with locals()["xyz"] Marko
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-02-23 10:30 +0000 |
| Message-ID | <5309cdc9$0$29985$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #66929 |
On Sun, 23 Feb 2014 11:52:05 +0200, Marko Rauhamaa wrote: > Steven D'Aprano <steve+comp.lang.python@pearwood.info>: > >> The big difference is that in "fixed location" languages, it makes >> sense to talk about the address of a *variable*. > > The address could be a symbol, too. > > The Python statement > > xyz = 3 > > places a number in the address "xyz". It doesn't matter whether addresses are numeric or symbolic, Python does not use that model for variables. Consider this example. There are a few steps, so let's go through them. First we prove that so-called address "abc" and "xyz" are distinct. If they were the same address, then they would logically have to contain the same value, but that is not the case: abc = 23 xyz = 42 assert abc != xyz This proves that the two addresses are different. Now we prove that they are the same address: abc = xyz = [] xyz.append(42) assert abc == [42] If they were different, then modifying the object at xyz cannot modify the object at abc. So we have a contradiction: "addresses" abc and xyz are both the same address, and different addresses. There is a way to wiggle out of the contradiction: accept that the addresses are distinct, but claim that a single object can be in two different locations at once. But if we make that argument, we are stretching the metaphor of location quite considerably. Absent time- travel, objects cannot be in two locations at once. Claiming that they can be requires stretching the metaphor of location past breaking point. Self-confession time: some years ago, I used to make exactly that argument. I used to argue that the right way to visualise Python's variable model was to consider that objects were stored in variables in exactly the way you are suggesting. I didn't describe them as symbolic addresses, but otherwise the model was the same. In order to make the model work, I argued that objects could be in more than one place at once, including *inside* itself: L = [] L.append(L) and explicitly argued that this didn't matter. After all, if I can watch Doctor Who and accept the concept of his TARDIS materialising inside itself, I can understand the idea of a list being inside itself. That was before I really grasped the difference between the name binding and fixed location variable models. While I'm still fond of the concept of a box being inside itself, I've come to understand that having to stretch the metaphor of location so far simply indicates that the metaphor does not work with Python's semantics. Python's actual behaviour is not a good fit for the "variables are locations" model, not even if you think of locations in the abstract with symbolic names rather the numeric addresses. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-23 21:32 +1100 |
| Message-ID | <mailman.7286.1393151578.18130.python-list@python.org> |
| In reply to | #66929 |
On Sun, Feb 23, 2014 at 8:52 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
> Steven D'Aprano <steve+comp.lang.python@pearwood.info>:
>
>> The big difference is that in "fixed location" languages, it makes
>> sense to talk about the address of a *variable*.
>
> The address could be a symbol, too.
>
> The Python statement
>
> xyz = 3
>
> places a number in the address "xyz".
>
> You can read the value from the address "xyz" with
>
> locals()["xyz"]
No, you cannot. That's the exact line of thinking that leads to
problems. You are not placing a number at the address "xyz", you are
pointing the name "xyz" to the number 3. That number still exists
elsewhere.
xyz = 3
abc = xyz
Does this copy the 3 from xyz into abc? In C, it would. Those
variables might not "exist" anywhere, but they must, by definition, be
storing the integer 3. And that integer has been copied. But in
Python, no it does not. It doesn't *copy* anything. And if you fiddle
with the integer 3 in some way, making it different, it'll be
different whether you look at xyz or abc, because they're the same 3.
You can't see that with integers because Python's int is immutable,
but this is where the confusion about mutable vs immutable objects
comes from. Immutable objects behave *sufficiently similarly* to the
C/Pascal model that it's possible to think Python works the same way,
but it doesn't.
The nearest C equivalent to what I'm talking about is pointers.
(CPython objects are basically used with pointers anyway. When you get
back an object reference from a CPython API function, you get a
pointer, optionally with the responsibility for one of its
references.) This is broadly how Python objects work:
/* Python strings are immutable, so the equivalent would be a list. */
/* I'm using a string because C doesn't have a list type. */
char *xyz = strcpy(malloc(20),"Hello, world!");
char *abc = xyz;
xyz[1] = 'a';
printf("abc has: %s\n", abc);
That'll show that abc has "Hallo, world!", even though it was through
xyz that the change was made. The "thing" that is that string is the
puddle of bytes on the heap (allocated with the malloc(20) up above).
The name just has a reference to that. Creating another reference to
the same object doesn't change anything.
ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-02-23 13:01 +0200 |
| Message-ID | <87ob1yay9m.fsf@elektro.pacujo.net> |
| In reply to | #66935 |
Chris Angelico <rosuav@gmail.com>: > That's the exact line of thinking that leads to problems. You are not > placing a number at the address "xyz", you are pointing the name "xyz" > to the number 3. That number still exists elsewhere. And? In C, I can say: Number *o = malloc(sizeof *o); o->value = 3; Your statement is valid: the number 3 resides elsewhere than the variable o. As for Python, there's nothing in the Python specification that would prevent you from having, say, 63-bit integers as representing themselves. IOW, you could physically place such integers as themselves as the reference and the number would not physically exist elsewhere. Bottom line, there's no fundamental difference between C and Python variables. Marko
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-23 22:12 +1100 |
| Message-ID | <mailman.7287.1393153954.18130.python-list@python.org> |
| In reply to | #66936 |
On Sun, Feb 23, 2014 at 10:01 PM, Marko Rauhamaa <marko@pacujo.net> wrote: > As for Python, there's nothing in the Python specification that would > prevent you from having, say, 63-bit integers as representing > themselves. IOW, you could physically place such integers as themselves > as the reference and the number would not physically exist elsewhere. What would id(5) be? Some constant? What would id(id([])) be? ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-02-23 17:24 +0200 |
| Message-ID | <87k3clc0n9.fsf@elektro.pacujo.net> |
| In reply to | #66937 |
Chris Angelico <rosuav@gmail.com>: > On Sun, Feb 23, 2014 at 10:01 PM, Marko Rauhamaa <marko@pacujo.net> wrote: >> As for Python, there's nothing in the Python specification that would >> prevent you from having, say, 63-bit integers as representing >> themselves. IOW, you could physically place such integers as >> themselves as the reference and the number would not physically exist >> elsewhere. > > What would id(5) be? Some constant? What would id(id([])) be? Any suitable scheme would do. For example, id(n) == n for 63-bit integers; other objects are dynamically sequence-numbered starting from a high base (here, 2 ** 64): >>> id(5) 5 >>> id([]) 18446744073709551620 >>> id(id([])) 18446744073709551624 Or id(n) == 2 * n for 63-bit integers; other objects are dynamically sequence-numbered using only odd integers starting from 1: >>> id(5) 10 >>> id([]) 7 >>> id(id([])) 18 Or id(n) == 2 ** 64 + n for 63-bit integers; other objects get the RAM address of the internal ḿemory block: >>> id(5) 18446744073709551621 >>> id([]) 3074657068 >>> id(id([])) 18446744076784207372 The possibilities are endless. Marko
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-24 02:41 +1100 |
| Message-ID | <mailman.7290.1393170116.18130.python-list@python.org> |
| In reply to | #66942 |
On Mon, Feb 24, 2014 at 2:24 AM, Marko Rauhamaa <marko@pacujo.net> wrote: > Or id(n) == 2 ** 64 + n for 63-bit integers; other objects get the > RAM address of the internal ḿemory block: > > >>> id(5) > 18446744073709551621 > >>> id([]) > 3074657068 > >>> id(id([])) > 18446744076784207372 Assuming you define "63-bit integers" either as 0<=n<2**63 or as -2**62<=n<2**62, this could work, but it would depend on never using memory with addresses with bit 63 set, as id() is (if I recall correctly) supposed to return an integer in the native range. I'm not sure you can depend on that sort of pattern of memory usage. In any case, you'd need some way to pretend that every integer is really an object, so you'd need to define id(), the 'is' operator, and everything else that can work with objects, to ensure that they correctly handle this. It would be a reasonable performance improvement to use native integers for the small ones (where "small" integers might still be fairly large by human standards), but unlike in languages like Pike (which does something like what you're saying), Python has a concept of "object identity" which can't be broken. (Pike's integers simply _are_, they aren't considered separate objects. You can't test them for identity. Its strings, also, simply are, although since Pike strings are guaranteed to be interned, their values and identities really are the same. To Pike, it's only more complex types that need to distinguish value from identity.) So this optimization, which certainly does make sense on the face of it, would potentially make a mess of things elsewhere. I'm sure PyPy optimizes small integers somewhat, though. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-02-23 23:04 +0200 |
| Message-ID | <87eh2t1qxp.fsf@elektro.pacujo.net> |
| In reply to | #66943 |
Chris Angelico <rosuav@gmail.com>: > id() is (if I recall correctly) supposed to return an integer in the > native range That restriction seems beyond the scope of the language definition. Still, it can be trivially provided for. > In any case, you'd need some way to pretend that every integer is > really an object, so you'd need to define id(), the 'is' operator, and > everything else that can work with objects, to ensure that they > correctly handle this. Trivial, I should say. > It would be a reasonable performance improvement to use native > integers for the small ones Maybe. Point is, whether it's done this way or that is irrelevant from the point of view of functional correctness. Whether an integer is an object or not has absolutely nothing to do with the implementation of the interpreter. And thus, Python variables are barely distinguishable from C variables. Marko
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2014-02-23 21:18 +0000 |
| Message-ID | <mailman.7295.1393190321.18130.python-list@python.org> |
| In reply to | #66948 |
On 23/02/2014 21:04, Marko Rauhamaa wrote: > > And thus, Python variables are barely distinguishable from C variables. > To repeat what Terry Reedy said earlier, hogwash. Looks as if I've another member of my dream team, who can proudly sit alongside our self appointed resident unicode expert. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-02-23 12:06 -0500 |
| Message-ID | <mailman.7294.1393175193.18130.python-list@python.org> |
| In reply to | #66936 |
On 2/23/2014 6:01 AM, Marko Rauhamaa wrote: > As for Python, there's nothing in the Python specification that would > prevent you from having, say, 63-bit integers as representing > themselves. IOW, you could physically place such integers as themselves > as the reference and the number would not physically exist elsewhere. The Python spec requires that ints act as if they are independent objects with about 20 attributes and methods. The language spec is based on duck typing everything as an object with a class and attributes. Revised code would have to either turn the reference int into a real object on every access (which would be tremendously inefficient), or code special case treatment of reference ints into *every* piece code that might act on ints (which is all over the interpreter) so as to simulate the int object behavior. id(someint) is the least of the problems. Special-casing ints to store the value in the reference has been proposed and rejected. I do not remember how far anyone went in trying to code the idea, but I doubt that anyone got as far as getting the test suite to pass. > Bottom line, there's no fundamental difference between C and Python > variables. Hogwash. Int variables are not all variables. And as I explained above, even if one stored Python ints much like C ints, one would have to add code to hide the fact that one had done so. -- Terry Jan Reedy
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-02-23 23:10 +0200 |
| Message-ID | <87a9dh1qnn.fsf@elektro.pacujo.net> |
| In reply to | #66945 |
Terry Reedy <tjreedy@udel.edu>: > Special-casing ints to store the value in the reference has been > proposed and rejected. I do not remember how far anyone went in trying > to code the idea, but I doubt that anyone got as far as getting the > test suite to pass. FWIW, elisp essentially does that. Anyway, we are discussing this to make it clear that the language definition is abstract. All compliant implementations are equally correct. It doesn't make any difference whatsoever for a Python programmer how this or that object type has been implemented under the hood. > Hogwash. Int variables are not all variables. And as I explained > above, even if one stored Python ints much like C ints, one would have > to add code to hide the fact that one had done so. <URL: http://www.brainyquote.com/quotes/quotes/s/salvadorda103580.html> The only difference between me and a madman is that I'm not mad. Marko
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2014-02-24 00:37 +0000 |
| Message-ID | <530a9455$0$29985$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #66949 |
On Sun, 23 Feb 2014 23:10:36 +0200, Marko Rauhamaa wrote: > Terry Reedy <tjreedy@udel.edu>: > >> Special-casing ints to store the value in the reference has been >> proposed and rejected. I do not remember how far anyone went in trying >> to code the idea, but I doubt that anyone got as far as getting the >> test suite to pass. > > FWIW, elisp essentially does that. Anyway, we are discussing this to > make it clear that the language definition is abstract. No. The language definition is concrete: it describes a concrete interface. You are confusing the interface with the implementation: the language definition is only abstract with regard to the implementation, which is free to vary, so long as the interface remains the same. Regardless of the implementation, Python code must behave in certain ways, and the reference implementation CPython defines the semantics of variable as name binding, not fixed locations. Can this by implemented using fixed locations? Of course it can, and is: the proof is that CPython's name binding variables are implemented in C, which uses fixed location variables. > All compliant > implementations are equally correct. It doesn't make any difference > whatsoever for a Python programmer how this or that object type has been > implemented under the hood. Performance can matter :-) But you are correct, as far as it goes. Where you are going wrong is by confusing the semantics of Python code with the underlying implementation of the Python virtual machine. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | wxjmfauth@gmail.com |
|---|---|
| Date | 2014-02-24 01:35 -0800 |
| Message-ID | <99e1e365-e246-49bc-913a-ac62ba7aaf80@googlegroups.com> |
| In reply to | #66952 |
Le lundi 24 février 2014 01:37:42 UTC+1, Steven D'Aprano a écrit :
>
>
>
> Performance can matter :-)
>
>
>
>>> timeit.timeit("'abc' * 1000 + 'z'")
0.991999136702321
>>> timeit.timeit("'abc' * 1000 + '\N{EURO SIGN}'")
2.5462559386176444
>>>
Two points to notice
- Even with utf-8, the worse performance case, such
a difference reaches [0.x - a few] percent.
- Indexing? Very well preserved for the "abc part"
jmf
[toc] | [prev] | [next] | [standalone]
| From | j.e.haque@gmail.com |
|---|---|
| Date | 2014-02-24 10:05 -0800 |
| Message-ID | <08aa32de-cd51-4888-bd60-2c2b53d86ecc@googlegroups.com> |
| In reply to | #66936 |
On Sunday, February 23, 2014 5:01:25 AM UTC-6, Marko Rauhamaa wrote:
> Chris Angelico <rosuav@gmail.com>:
>
> > That's the exact line of thinking that leads to problems. You are not
>
> > placing a number at the address "xyz", you are pointing the name "xyz"
>
> > to the number 3. That number still exists elsewhere.
>
>
>
> And?
>
>
>
> In C, I can say:
>
>
>
> Number *o = malloc(sizeof *o);
>
> o->value = 3;
>
>
>
> Your statement is valid: the number 3 resides elsewhere than the
>
> variable o.
typedef struct {
int value;
} Number;
Number *o;
o = malloc(sizeof(*o));
o->value=3;
printf("o<%p>, o->value<%p>\n", o, &o->value);
o<0x9fe5008>, o->value<0x9fe5008>
Is the compiler borked?
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2014-02-24 11:19 -0700 |
| Subject | Re: [OT] Can global variable be passed into Python function? |
| Message-ID | <mailman.7319.1393265975.18130.python-list@python.org> |
| In reply to | #66987 |
On 02/24/2014 11:05 AM, j.e.haque@gmail.com wrote:
> typedef struct {
> int value;
> } Number;
>
> Number *o;
> o = malloc(sizeof(*o));
> o->value=3;
> printf("o<%p>, o->value<%p>\n", o, &o->value);
>
> o<0x9fe5008>, o->value<0x9fe5008>
>
> Is the compiler borked?
Why would you think that? The address of the start of your malloc'ed
structure is the same as the address of the first element. Surely this
is logical? And of course all this is quite off topic.
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-02-24 19:42 +0000 |
| Subject | Re: [OT] Can global variable be passed into Python function? |
| Message-ID | <leg7au$ckp$2@reader1.panix.com> |
| In reply to | #66988 |
On 2014-02-24, Michael Torrie <torriem@gmail.com> wrote:
> On 02/24/2014 11:05 AM, j.e.haque@gmail.com wrote:
>> typedef struct {
>> int value;
>> } Number;
>>
>> Number *o;
>> o = malloc(sizeof(*o));
>> o->value=3;
>> printf("o<%p>, o->value<%p>\n", o, &o->value);
>>
>> o<0x9fe5008>, o->value<0x9fe5008>
>>
>> Is the compiler borked?
>
> Why would you think that? The address of the start of your malloc'ed
> structure is the same as the address of the first element. Surely
> this is logical?
Not only is it logical, the C standard explicitly requires it. Here's
a second-hand citation since I don't happend to have an actual copy of
the standard on hand:
C1x §6.7.2.1.13:
A pointer to a structure object, suitably converted, points to
its initial member ... and vice versa. There may be unnamed
padding within a structure object, but not at its beginning.
--
Grant Edwards grant.b.edwards Yow! I'm gliding over a
at NUCLEAR WASTE DUMP near
gmail.com ATLANTA, Georgia!!
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-03-01 23:02 -0500 |
| Subject | Re: [OT] Can global variable be passed into Python function? |
| Message-ID | <mailman.7560.1393732703.18130.python-list@python.org> |
| In reply to | #67356 |
Grant Edwards <invalid@invalid.invalid> Wrote in message: > On 2014-02-24, Michael Torrie <torriem@gmail.com> wrote: > >> >> Why would you think that? The address of the start of your malloc'ed >> structure is the same as the address of the first element. Surely >> this is logical? > > Not only is it logical, the C standard explicitly requires it. Here's > a second-hand citation since I don't happend to have an actual copy of > the standard on hand: > > C1x �6.7.2.1.13: > > A pointer to a structure object, suitably converted, points to > its initial member ... and vice versa. There may be unnamed > padding within a structure object, but not at its beginning. The quote you make from the C standard doesn't mention malloc, so you're arguing different things. It's not the compiler that casts the malloc return value to the struct type. C++ does implicitly convert the result, and the return value of new already has the struct type. But the runtime stores at least two kinds of overhead on occasion, the array size, and the vtable. So the malloc address can not be assumed to match the struct beginning. (Not even considering that one can override operator new at two levels) Glad python doesn't have any of this mess. -- DaveA
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-03-02 16:45 +0000 |
| Subject | Re: [OT] Can global variable be passed into Python function? |
| Message-ID | <levn78$mkq$1@reader1.panix.com> |
| In reply to | #67407 |
On 2014-03-02, Dave Angel <davea@davea.name> wrote: > Grant Edwards <invalid@invalid.invalid> Wrote in message: >> On 2014-02-24, Michael Torrie <torriem@gmail.com> wrote: >> >>> >>> Why would you think that? The address of the start of your malloc'ed >>> structure is the same as the address of the first element. Surely >>> this is logical? >> >> Not only is it logical, the C standard explicitly requires it. Here's >> a second-hand citation since I don't happend to have an actual copy of >> the standard on hand: >> >> C1x ???6.7.2.1.13: >> >> A pointer to a structure object, suitably converted, points to >> its initial member ... and vice versa. There may be unnamed >> padding within a structure object, but not at its beginning. > > The quote you make from the C standard doesn't mention malloc, so > you're arguing different things. No, I'm not. A pointer to a structure object and a pointer to it's first field are the same. It doesn't matter where the object came from. > It's not the compiler that casts the malloc return value to the > struct type. That's irrelevent. The actual location of the memory containing the struct object (static, stack, heap, shared) doesn't matter. The address of the first field in a struture object _is_ the address of the structure object. -- Grant
[toc] | [prev] | [next] | [standalone]
Page 3 of 11 — ← Prev page 1 2 [3] 4 5 … 11 Next page →
Back to top | Article view | comp.lang.python
csiph-web