Re: [PHP-DEV] stat/fstat
[Zeev Suraski [EMAIL PROTECTED]] Hey, I just got around to writing a PHP script that uses stat(), and was quite surprised to find that instead of using string indices, it uses hardcoded/obscure numeric indices, e.g.: Array ( [0] = 2050 [1] = 1114462 [2] = 16877 [3] = 2 [4] = 503 [5] = 513 [6] = 11065 [7] = 1024 [8] = 989532201 [9] = 989532201 [10] = 989532201 [11] = 4096 [12] = 2 ) Is there any reason for this? If not, I'd like to add meaningful names as well (I guess it's way too late to remove the numeric indices) Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. - Stig -- Stig Sæther Bakken [EMAIL PROTECTED] Fast Search Transfer ASA, Trondheim, Norway -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
On 11 May 2001, Stig Sæther Bakken wrote: Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. it's already implemented this way now (it was added last night) AFAIK Derick Rethans - PHP: Scripting the Web - www.php.net - [EMAIL PROTECTED] SRM: Site Resource Manager - www.vl-srm.net - -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
At 12:18 11/5/2001, Stig Sæther Bakken wrote: [Zeev Suraski [EMAIL PROTECTED]] Hey, I just got around to writing a PHP script that uses stat(), and was quite surprised to find that instead of using string indices, it uses hardcoded/obscure numeric indices, e.g.: Array ( [0] = 2050 [1] = 1114462 [2] = 16877 [3] = 2 [4] = 503 [5] = 513 [6] = 11065 [7] = 1024 [8] = 989532201 [9] = 989532201 [10] = 989532201 [11] = 4096 [12] = 2 ) Is there any reason for this? If not, I'd like to add meaningful names as well (I guess it's way too late to remove the numeric indices) Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. Yep, that's the best solution IMHO. Zeev -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Its actually not that pretty Since the entries are in a hashtable, you have to duplicate the values, with just another key. -Jason - Original Message - From: Brian Foddy [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: Stig Sæther Bakken [EMAIL PROTECTED]; PHP Developers Mailing List [EMAIL PROTECTED] Sent: Friday, May 11, 2001 10:21 AM Subject: Re: [PHP-DEV] stat/fstat [EMAIL PROTECTED] wrote: On 11 May 2001, Stig Sæther Bakken wrote: Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. it's already implemented this way now (it was added last night) AFAIK Derick Rethans You are creating the same array indexed both by a integer and a string? I'm curious how this is done. I might have a good use for this trick. Brian -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
On Fri, 11 May 2001, Jason Greene wrote: Its actually not that pretty Since the entries are in a hashtable, you have to duplicate the values, with just another key. You could just reuse the same value with refcount++ but that means you can't use nice add_* functions, gotta use zend_hash_* ones directly. ;-) -Andrei The Heineken Uncertainty Principle: You can never be sure how many beers you had last night. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Andrei had the same suggestion, so I went ahead and added it last night. -Jason - Original Message - From: Stig Sæther Bakken [EMAIL PROTECTED] To: Zeev Suraski [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, May 11, 2001 4:18 AM Subject: Re: [PHP-DEV] stat/fstat [Zeev Suraski [EMAIL PROTECTED]] Hey, I just got around to writing a PHP script that uses stat(), and was quite surprised to find that instead of using string indices, it uses hardcoded/obscure numeric indices, e.g.: Array ( [0] = 2050 [1] = 1114462 [2] = 16877 [3] = 2 [4] = 503 [5] = 513 [6] = 11065 [7] = 1024 [8] = 989532201 [9] = 989532201 [10] = 989532201 [11] = 4096 [12] = 2 ) Is there any reason for this? If not, I'd like to add meaningful names as well (I guess it's way too late to remove the numeric indices) Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. - Stig -- Stig Sæther Bakken [EMAIL PROTECTED] Fast Search Transfer ASA, Trondheim, Norway -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
On Fri, 11 May 2001, Jason Greene wrote: Its actually not that pretty Since the entries are in a hashtable, you have to duplicate the values, with just another key. You could just reuse the same value with refcount++ but that means you can't use nice add_* functions, gotta use zend_hash_* ones directly. ;-) True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) -Jason -Andrei The Heineken Uncertainty Principle: You can never be sure how many beers you had last night. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
On Fri, 11 May 2001, Jason Greene wrote: True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) 13 * sizeof(zval) actually. -Andrei When we eliminate the impossible, whatever remains, however improbable, must be true. -- Sherlock Holmes -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Ah yes, I stand corrected , 13 zvals : ) -Jason - Original Message - From: Andrei Zmievski [EMAIL PROTECTED] To: Jason Greene [EMAIL PROTECTED] Cc: Jason Greene [EMAIL PROTECTED]; Brian Foddy [EMAIL PROTECTED]; [EMAIL PROTECTED]; Stig Sæther Bakken [EMAIL PROTECTED]; PHP Developers Mailing List [EMAIL PROTECTED] Sent: Friday, May 11, 2001 11:38 AM Subject: Re: [PHP-DEV] stat/fstat On Fri, 11 May 2001, Jason Greene wrote: True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) 13 * sizeof(zval) actually. -Andrei When we eliminate the impossible, whatever remains, however improbable, must be true. -- Sherlock Holmes -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
At 18:21 11/5/2001, Brian Foddy wrote: [EMAIL PROTECTED] wrote: On 11 May 2001, Stig Sæther Bakken wrote: Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. it's already implemented this way now (it was added last night) AFAIK Derick Rethans You are creating the same array indexed both by a integer and a string? I'm curious how this is done. I might have a good use for this trick. No special tricks needed; PHP's arrays support both numeric and string indices ever since PHP 3.0 (at least). You can simply add both types of indices to the same array without having to do anything special. -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Zeev Suraski wrote: At 18:21 11/5/2001, Brian Foddy wrote: [EMAIL PROTECTED] wrote: On 11 May 2001, Stig Sæther Bakken wrote: Why not have both numerical and descriptive indices? Backwards compatible, slightly bloatish, but not really a problem. it's already implemented this way now (it was added last night) AFAIK Derick Rethans You are creating the same array indexed both by a integer and a string? I'm curious how this is done. I might have a good use for this trick. No special tricks needed; PHP's arrays support both numeric and string indices ever since PHP 3.0 (at least). You can simply add both types of indices to the same array without having to do anything special. Thanks everyone, I knew arrays could be one or the other, but never considered the same value with multiple indexes. I have a perfect use for this, where an array I build, the values have a int index value, and a string an equiv string name. I'm already doing the zend_hash_update and index_update functions anyway, so this should be pretty easy. Question, what will zend_hash_get_current_key return if it gets input like this? Brian -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
At 19:38 11/5/2001, Andrei Zmievski wrote: On Fri, 11 May 2001, Jason Greene wrote: True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) 13 * sizeof(zval) actually. 13*(sizeof(zval)+sizeof(zend_mem_header)), and possibly slightly more, actually :) Next thing you know you'd run out of memory just because of this. Zeev -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Well, due to the great interest in memory conservation, fstat and stat are now rewritten to share the vals across multiple keys : ) So now we are saving the user 13* sizeof(zval)+sizeof(zend_mem_header).+whatever of memory : ) -Jason - Original Message - From: Zeev Suraski [EMAIL PROTECTED] To: Andrei Zmievski [EMAIL PROTECTED] Cc: Jason Greene [EMAIL PROTECTED]; Jason Greene [EMAIL PROTECTED]; Brian Foddy [EMAIL PROTECTED]; [EMAIL PROTECTED]; Stig Sæther Bakken [EMAIL PROTECTED]; PHP Developers Mailing List [EMAIL PROTECTED] Sent: Friday, May 11, 2001 12:36 PM Subject: Re: [PHP-DEV] stat/fstat At 19:38 11/5/2001, Andrei Zmievski wrote: On Fri, 11 May 2001, Jason Greene wrote: True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) 13 * sizeof(zval) actually. 13*(sizeof(zval)+sizeof(zend_mem_header)), and possibly slightly more, actually :) Next thing you know you'd run out of memory just because of this. Zeev -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Yikes. We were only kidding, Jason :) At 23:00 11/5/2001, Jason Greene wrote: Well, due to the great interest in memory conservation, fstat and stat are now rewritten to share the vals across multiple keys : ) So now we are saving the user 13* sizeof(zval)+sizeof(zend_mem_header).+whatever of memory : ) -Jason - Original Message - From: Zeev Suraski [EMAIL PROTECTED] To: Andrei Zmievski [EMAIL PROTECTED] Cc: Jason Greene [EMAIL PROTECTED]; Jason Greene [EMAIL PROTECTED]; Brian Foddy [EMAIL PROTECTED]; [EMAIL PROTECTED]; Stig Sæther Bakken [EMAIL PROTECTED]; PHP Developers Mailing List [EMAIL PROTECTED] Sent: Friday, May 11, 2001 12:36 PM Subject: Re: [PHP-DEV] stat/fstat At 19:38 11/5/2001, Andrei Zmievski wrote: On Fri, 11 May 2001, Jason Greene wrote: True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) 13 * sizeof(zval) actually. 13*(sizeof(zval)+sizeof(zend_mem_header)), and possibly slightly more, actually :) Next thing you know you'd run out of memory just because of this. Zeev -- Zeev Suraski [EMAIL PROTECTED] CTO co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
At 03:31 AM 5/12/01 +0300, Zeev Suraski wrote: Yikes. We were only kidding, Jason :) Well, he could have the last argument of zend_hash_update() to receive the point to inserted value and done refcount++ on that and inserted again. ;-) I've been thinking we need to have add_* functions returning the pointer to inserted value somehow.. Plus the set of corresponding functions for retrieving data easily. -Andrei -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
Yikes. We were only kidding, Jason :) Ya , but you guys sparked that old memory efficiency routine in my brain from when I used to write assembly : ) Hey did you get a chance to read my fork() dev posting, and that email about assign-op's in zend_execute? I some advice/suggestions . Thanks, -Jason At 23:00 11/5/2001, Jason Greene wrote: Well, due to the great interest in memory conservation, fstat and stat are now rewritten to share the vals across multiple keys : ) So now we are saving the user 13* sizeof(zval)+sizeof(zend_mem_header).+whatever of memory : ) -Jason - Original Message - From: Zeev Suraski [EMAIL PROTECTED] To: Andrei Zmievski [EMAIL PROTECTED] Cc: Jason Greene [EMAIL PROTECTED]; Jason Greene [EMAIL PROTECTED]; Brian Foddy [EMAIL PROTECTED]; [EMAIL PROTECTED]; Stig Sæther Bakken [EMAIL PROTECTED]; PHP Developers Mailing List [EMAIL PROTECTED] Sent: Friday, May 11, 2001 12:36 PM Subject: Re: [PHP-DEV] stat/fstat At 19:38 11/5/2001, Andrei Zmievski wrote: On Fri, 11 May 2001, Jason Greene wrote: True, I was lazy though and didn't feel like writing all that additional code, just to save 13 longs of memory space : ) 13 * sizeof(zval) actually. 13*(sizeof(zval)+sizeof(zend_mem_header)), and possibly slightly more, actually :) Next thing you know you'd run out of memory just because of this. Zeev -- Zeev Suraski [EMAIL PROTECTED] CTO co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
At 03:31 AM 5/12/01 +0300, Zeev Suraski wrote: Yikes. We were only kidding, Jason :) Well, he could have the last argument of zend_hash_update() to receive the point to inserted value and done refcount++ on that and inserted again. ;-) The only thing with that method is that I was trying to place the hash table in true stat order, so that all the numeric keys are before the string keys, so that someone could easily move to the next element without getting a duplicate value. I suppose I could have created another zval * for each insret to catch the pointer the returned value, but I was trying to make the code is clean as possible, and it just seemed easier to start off declaring the zval with another refcount. I've been thinking we need to have add_* functions returning the pointer to inserted value somehow.. Plus the set of corresponding functions for retrieving data easily. -Andrei I agree, it seems that the add_ functions are so high level that it is common to switch to using the hash functions. However, the hash functions are often too low level, and add a lot of complexity. Some enhanced add functions would help out alot if nothing more then helping readibility of code : ) -Jason -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
I just figured this only applies to stat() and not fstat(). Which also means they're totally incompatible with each other, although the documentation suggests they're essentially the same, other than the fact that one expects a file handle and the other expects a file name... What gives? At 01:07 11/5/2001, Zeev Suraski wrote: Hey, I just got around to writing a PHP script that uses stat(), and was quite surprised to find that instead of using string indices, it uses hardcoded/obscure numeric indices, e.g.: Array ( [0] = 2050 [1] = 1114462 [2] = 16877 [3] = 2 [4] = 503 [5] = 513 [6] = 11065 [7] = 1024 [8] = 989532201 [9] = 989532201 [10] = 989532201 [11] = 4096 [12] = 2 ) Is there any reason for this? If not, I'd like to add meaningful names as well (I guess it's way too late to remove the numeric indices) Zeev -- Zeev Suraski [EMAIL PROTECTED] CTO co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Zeev Suraski [EMAIL PROTECTED] CTO co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DEV] stat/fstat
I ran into that a long time ago, and I wondered why. I thought about changing it, but I assumed that it would break backwards compatibility. What about 4.1 though? -Jason - Original Message - From: Zeev Suraski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 10, 2001 5:11 PM Subject: Re: [PHP-DEV] stat/fstat I just figured this only applies to stat() and not fstat(). Which also means they're totally incompatible with each other, although the documentation suggests they're essentially the same, other than the fact that one expects a file handle and the other expects a file name... What gives? At 01:07 11/5/2001, Zeev Suraski wrote: Hey, I just got around to writing a PHP script that uses stat(), and was quite surprised to find that instead of using string indices, it uses hardcoded/obscure numeric indices, e.g.: Array ( [0] = 2050 [1] = 1114462 [2] = 16877 [3] = 2 [4] = 503 [5] = 513 [6] = 11065 [7] = 1024 [8] = 989532201 [9] = 989532201 [10] = 989532201 [11] = 4096 [12] = 2 ) Is there any reason for this? If not, I'd like to add meaningful names as well (I guess it's way too late to remove the numeric indices) Zeev -- Zeev Suraski [EMAIL PROTECTED] CTO co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- Zeev Suraski [EMAIL PROTECTED] CTO co-founder, Zend Technologies Ltd. http://www.zend.com/ -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Development Mailing List http://www.php.net/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]