Just genuinely curious, say I have a url ending in the following /home?id=2. Which is more efficient to use to obtain the id value from the url, request.args['id'] or request.args.get('id')?
            Asked
            
        
        
            Active
            
        
            Viewed 387 times
        
    0
            
            
        
        Simon Melouah
        
- 642
 - 4
 - 11
 - 24
 
- 
                    `request.args` is a dictionary. `request.args['id']` this is fetching value from key(`id`) and `request.args.get('id')` call `get` function to fetch 'id' key value. – Vishnu Upadhyay Sep 22 '15 at 09:25
 - 
                    1...they're both a *"dictionary approach"*. The only difference is that [`.get(...)`](https://docs.python.org/2/library/stdtypes.html#dict.get) will return `None` if the key isn't found instead of throwing a `KeyError`. I would expect almost no difference in speed at all, but you could `timeit` if you really wanted - this is unlikely to be a bottleneck in your program. – jonrsharpe Sep 22 '15 at 09:37